[docs] [issue23750] Clarify difference between os.system/subprocess.call in section "Replacing os.system()"
Martin Panter
report at bugs.python.org
Tue Mar 24 02:52:35 CET 2015
Martin Panter added the comment:
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]
----------
nosy: +vadmium
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23750>
_______________________________________
More information about the docs
mailing list