I'm a new bie to python. Recently, I face a problem with Python Popen, and hope someone can help me. Thanks :D
a.py
#!/usr/bin/env python
import b
b.run()
while True:
pass
b.py
#!/usr/bin/env python
import subprocess
def run():
subprocess.Popen(['ping www.google.com > /dev/null &'], shell=True)
run()
When run b.py and grep process status
$ ps aux | grep
test 35806 0.0 0.0 2451284 592 s010 Sl 10:11 0:00.00 ping www.google.com
the ping process runs in background with STATE Sl.
And now I try run a.py
$ ps aux | grep
test 36088 0.0 0.0 2444116 604 s010 Sl+ 10:15 0:00.00 ping www.google.com
ping process STATE changes to Sl+, and if I stop a.py with ctrl + c
, ping process also terminated.
Is there any way to make ping process to run in backgroud, and it will not be affected when I stop a.py? And why ping process STATE changes from Sl to Sl+?