New submission from Creideiki <creideiki+pythonb...@ferretporn.se>: This is Python 2.7.14 on Gentoo Linux.
I ran into an issue where a program crashes if I run it from a terminal, put it in the background, and then close the terminal too soon. Upstream bug report: https://github.com/micahflee/torbrowser-launcher/issues/298 It seems the cause is that a print() call without a newline ignores the EIO returned by the write() syscall, but if there is a newline in the string, that EIO is suddenly a fatal error. Reproducer: $ cat fatal.py #!/bin/env python2.7 import time time.sleep(5) print('A') print('B\nC') print('D') Run this program in the background under strace to see what it does, and while it is sleeping, close its controlling terminal: $ strace -s 256 -o fatal.log -f ./fatal.py & [1] 17974 ^d Now look at the strace log: $ grep write fatal.log 17978 write(1, "A\n", 2) = -1 EIO (Input/output error) 17978 write(1, "B\n", 2) = -1 EIO (Input/output error) 17978 write(2, "Traceback (most recent call last):\n", 35) = -1 EIO (Input/output error) 17978 write(2, " File \"./fatal.py\", line 5, in <module>\n", 41) = -1 EIO (Input/output error) 17978 write(2, " ", 4) = -1 EIO (Input/output error) 17978 write(2, "print('B\\nC')\n", 14) = -1 EIO (Input/output error) 17978 write(2, "IOError", 7) = -1 EIO (Input/output error) 17978 write(2, ": ", 2) = -1 EIO (Input/output error) 17978 write(2, "[Errno 5] Input/output error", 28) = -1 EIO (Input/output error) 17978 write(2, "\n", 1) = -1 EIO (Input/output error) The first print('A') ran and had an EIO error, which was ignored. The second print('B\nC') tried to write 'B', had an EIO error, and crashed. The third print('D') was never attempted. ---------- components: IO messages: 308468 nosy: Creideiki priority: normal severity: normal status: open title: EIO from write() is only fatal if print() contains a newline versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32345> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com