문제

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 available 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
>>>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top