This page is about a bug in Linux's handling of non-blocking files.
To see the bug, you need to do a blocking write to the inode. If this blocks, then that process will hold the atomic_write semaphore. While that write is still blocked, do a non-blocking write to the same inode. The result is that the non-blocking write blocks while trying to acquire the semaphore.
These conditions happen in practice when using the 'wall' program. If a program writing to a tty blocks due to the terminal being stopped, the wall process will hang on writing to that tty. Later, when the terminal is unblocked or hung up, the wall program continues and delivers the message late to other terminals.
The following programs will demonstrate the bug. If your system has the bug, you will see the message "write blocked despite file descriptor being non-blocking!" If you see "test failed", the program was unable to complete the test and you should run the test again.
Note: The tty test should be compiled with -D_XOPEN_SOURCE to get the definition of grantpt.
|Kernel||TTY test||Pipe test||TTY patch||Pipe patch|
Peter Benie <firstname.lastname@example.org>