Message239087
Another difference is that (at least POSIX) system() blocks SIGINT and SIGQUIT while the child is running. Compare:
$ python3 -c 'print("Waiting"); import os; print("Returned", os.system("sleep 3 && exit 3"))'
Sleeping
Returned 768
$ python3 -c 'print("Sleeping"); import os; print("Returned", os.system("sleep 3 && exit 3"))'
Waiting
^CReturned 2 # Hit Ctrl+C during sleep command
$ python3 -c 'print("Sleeping"); import subprocess; print("Returned", subprocess.call("sleep 3 && exit 3", shell=True))'
Sleeping
Returned 3
$ python3 -c 'print("Sleeping"); import subprocess; print("Returned", subprocess.call("sleep 3 && exit 3", shell=True))'
Sleeping
^CTraceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.4/subprocess.py", line 539, in call
return p.wait(timeout=timeout)
File "/usr/lib/python3.4/subprocess.py", line 1566, in wait
(pid, sts) = self._try_wait(0)
File "/usr/lib/python3.4/subprocess.py", line 1514, in _try_wait
(pid, sts) = _eintr_retry_call(os.waitpid, self.pid, wait_flags)
File "/usr/lib/python3.4/subprocess.py", line 491, in _eintr_retry_call
return func(*args)
KeyboardInterrupt
[Exit 1] |
|
Date |
User |
Action |
Args |
2015-03-24 01:52:35 | martin.panter | set | recipients:
+ martin.panter, docs@python, AndiDog |
2015-03-24 01:52:35 | martin.panter | set | messageid: <1427161955.09.0.563696841636.issue23750@psf.upfronthosting.co.za> |
2015-03-24 01:52:35 | martin.panter | link | issue23750 messages |
2015-03-24 01:52:34 | martin.panter | create | |
|