Le jeudi 20 février 2014 17:40:13 UTC+1, Victor Stinner a écrit : > > Output of "python3 tty_stat.py|python3 tty_stat.py": > --- > [10701] stdin: TTY? True, device 11.5 > [10702] stdin: TTY? False, device 8.60938304 > [10701] stdout: TTY? False, device 8.60938304 > [10702] stdout: TTY? True, device 11.5 > --- > > As expected, the stdin of the reader is connected to the stdout of the > writer: it's the pipe 8.60938304. > > But the stdin of the reader and the stdout of the writer are the same > TTY: device 11.5. > That is because the stdin of the first process and the stdout of the last process are attached to slave side of the pseudo terminal. (One is reading, the other is writing, but it's the same file descriptor.)
Setting the O_NONBLOCK flag on a TTY affects all processes. asyncio > should not do that, but it means that os.read() or os.write() might > block!? > That sounds like a nasty consequence. I had no idea that these flags were shared among processes. So it is impossible to have one process doing a blocking write to the pseudo terminal and another process a non blocking read. Right? Probably, then it'll get even more confusing when we spawn subprocesses and they all write to stdout. If they share the same file descriptors (what is normally on a fork/exec), the O_NONBLOCK flag is also shared among these subprocesses? Victor >
