Python - SIGPIPE handled bug
Dieter Maurer
dieter at handshake.de
Sun Jan 23 05:10:43 EST 2000
More information about the Python-list mailing list
Sun Jan 23 05:10:43 EST 2000
- Previous message (by thread): Python - SIGPIPE handled bug
- Next message (by thread): Python - SIGPIPE handled bug
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hallo Randall Randall Hopper <aa8vb at yahoo.com> writes on Fri, 21 Jan 2000 16:29:25 -0500: > > python -c "for i in xrange(1000): print 'Some output'" | head -2 > Some output > Some output > Traceback (innermost last): > File "<string>", line 1, in ? > IOError: [Errno 32] Broken pipe > --------------------------------------------------------------------------- > > python getting a SIGPIPE is appropriate behavior. "Whether" it gets a > SIGPIPE is up to the shell, in UNIX: It seems, that in your case Python does not get a SIGPIPE but the "write" returns "-1" and "errno==EPIPE". According to POSIX, this is the behaviour, if SIGPIPE is not handled by the default action: EPIPE fd is connected to a pipe or socket whose reading end is closed. When this happens the writing pro cess will receive a SIGPIPE signal; if it catches, blocks or ignores this the error EPIPE is returned. The SIGPIPE handling under Python 1.5.2/Linux 2/Bash seems to be to ignore the signal (possibly inherited from the bash!). If you do not like this, use: import signal signal.signal(signal.SIGPIPE,signal.SIG_DFL) Dieter
- Previous message (by thread): Python - SIGPIPE handled bug
- Next message (by thread): Python - SIGPIPE handled bug
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list