Message308468
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. |
|
| Date |
User |
Action |
Args |
| 2017-12-16 09:28:32 | Creideiki | set | recipients:
+ Creideiki |
| 2017-12-16 09:28:32 | Creideiki | set | messageid: <1513416512.67.0.213398074469.issue32345@psf.upfronthosting.co.za> |
| 2017-12-16 09:28:32 | Creideiki | link | issue32345 messages |
| 2017-12-16 09:28:31 | Creideiki | create | |
|