-
Nadav Har'El authored
This patch adds pipe(). The pipes are built using the same FIFO implementation, "af_local_buffer", as used by the existing unix-domain socketpair implementation - while the socket-pair used two of these buffers, a pipe uses one. This implementation deviates from traditional POSIX pipe behavior in two ways that we should fix in followup-patches: 1. SIGPIPE is not supported: A write to a pipe whose read end is closed will always return EPIPE, and not generate a SIGPIPE signal. Programs that rely on SIGPIPE will break, but SIGPIPE is completely out of fashion, and normally ignored. 2. Unix-style "atomic writes" are not obeyed. A write(), even if smaller than PIPE_BUF (=4096 on Linux, whose ABI we're emulating), may partially succeed if the pipe's buffer is nearly full. Only a write() of a single byte is guaranteed to be atomic. We hope that Java doesn't rely on multi-byte write() atomicity (single-byte writes are enough for waking poll, for example), and users of Java's "Pipe" class definitely can't (as Java is not Posix-only), so we hope this will not cause problems. Fixing this issue (which is easy) is left as a TODO in the code. Additionally, this patch marks with a FIXME (but doesn't fix) a serious bug in the code's iovec handling, so writev() and readv() are expected not to work in this version of pipe() - and also on the existing socketpair.
Nadav Har'El authoredThis patch adds pipe(). The pipes are built using the same FIFO implementation, "af_local_buffer", as used by the existing unix-domain socketpair implementation - while the socket-pair used two of these buffers, a pipe uses one. This implementation deviates from traditional POSIX pipe behavior in two ways that we should fix in followup-patches: 1. SIGPIPE is not supported: A write to a pipe whose read end is closed will always return EPIPE, and not generate a SIGPIPE signal. Programs that rely on SIGPIPE will break, but SIGPIPE is completely out of fashion, and normally ignored. 2. Unix-style "atomic writes" are not obeyed. A write(), even if smaller than PIPE_BUF (=4096 on Linux, whose ABI we're emulating), may partially succeed if the pipe's buffer is nearly full. Only a write() of a single byte is guaranteed to be atomic. We hope that Java doesn't rely on multi-byte write() atomicity (single-byte writes are enough for waking poll, for example), and users of Java's "Pipe" class definitely can't (as Java is not Posix-only), so we hope this will not cause problems. Fixing this issue (which is easy) is left as a TODO in the code. Additionally, this patch marks with a FIXME (but doesn't fix) a serious bug in the code's iovec handling, so writev() and readv() are expected not to work in this version of pipe() - and also on the existing socketpair.