开发者

mount command pid

开发者 https://www.devze.com 2022-12-26 14:17 出处:网络
Trying to mount a device and get the pid of mount command. cmd="/bin/mount /dev/sda1 /mnt" os.system(cmd)

Trying to mount a device and get the pid of mount command.

cmd="/bin/mount /dev/sda1 /mnt"

os.system(cmd)

Now how to obtain the pid of mount command? There plenty of mounted device avail开发者_如何学JAVAable on my system, something like ps | grep mount won't work.


As the comments suggest I'm not sure how useful it is to get the mount pid, but if you use the subprocess module you can easily get the pid.

>>> import subprocess
>>> p = subprocess.Popen("ls", shell=True)
>>> p.pid
4136
>>>
0

精彩评论

暂无评论...
验证码 换一张
取 消