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 ulidtko
Recipients ulidtko
Date 2011-03-03.01:32:45
SpamBayes Score 1.3387651e-06
Marked as misclassified No
Message-id <>
The following script fails:

from time import sleep

    while True:
        print "blah"
except KeyboardInterrupt:

when being launched with redirections like this:
$ python | tee /dev/null

and the tee process gots killed *before* the python process (by e.g. hitting ^C in most shells). The output is:

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr

When the python process is SIGINTed prior to the tee process, everything goes as expected: buffered output to stdout gots flushed and seen on the console, the script finishes successfully, with zero exit status, tee finishes too. When the tee receives SIGINT first, and then python, script loses the output and prints the mentioned message. strace shows that python is receiving (but probably not handling properly) "Broken pipe" error in response to write(2):
[pid 17874] write(1, "blah\nblah\nblah\nblah\nblah\nblah\nbl"..., 680) = -1 EPIPE (Broken pipe)
Date User Action Args
2011-03-03 01:32:46ulidtkosetrecipients: + ulidtko
2011-03-03 01:32:46ulidtkosetmessageid: <>
2011-03-03 01:32:45ulidtkolinkissue11380 messages
2011-03-03 01:32:45ulidtkocreate