Author martin.panter
Recipients AndiDog, docs@python, martin.panter
Date 2015-03-24.01:52:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427161955.09.0.563696841636.issue23750@psf.upfronthosting.co.za>
In-reply-to
Content
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]
History
Date User Action Args
2015-03-24 01:52:35martin.pantersetrecipients: + martin.panter, docs@python, AndiDog
2015-03-24 01:52:35martin.pantersetmessageid: <1427161955.09.0.563696841636.issue23750@psf.upfronthosting.co.za>
2015-03-24 01:52:35martin.panterlinkissue23750 messages
2015-03-24 01:52:34martin.pantercreate