This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chris.jerdonek
Recipients chris.jerdonek
Date 2015-12-27.10:58:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I came across a situation where Popen.wait() hangs and os.waitpid() doesn't hang.  It seems like a bug, but I don't know for sure.  This is with Python 3.5.1.

To reproduce, save the following to

    import os, signal, subprocess

    class State:
        process = None

    def handle_signal(signalnum, frame):
        print("Handling: {0}".format(signalnum))
        p = State.process
        # The following line hangs:
        # However, this line does not hang:
        # os.waitpid(, 1)
        print("Done waiting")

    signal.signal(signal.SIGINT, handle_signal)
    p = subprocess.Popen("while true; do echo sleeping; sleep 2; done",
    State.process = p

Then run the following, hit Control-C, and it will hang:

    $ python 
    ^CHandling: 2

It will still hang if you insert "p.terminate()" right before p.wait().

However, calling "os.waitpid(, ...)" instead of p.wait() exits immediately and does not hang.  The behavior also occurs without shell=True.
Date User Action Args
2015-12-27 10:58:02chris.jerdoneksetrecipients: + chris.jerdonek
2015-12-27 10:58:02chris.jerdoneksetmessageid: <>
2015-12-27 10:58:02chris.jerdoneklinkissue25960 messages
2015-12-27 10:58:01chris.jerdonekcreate