Medium
Writing to a pipe after the reader closes
SIGPIPE is left at its default disposition (not ignored, no handler installed). What actually happens when write() is called on the write end of a pipe whose read end has already been closed?
main.cpp
#include <unistd.h>
#include <cstdio>
int main() {
int fds[2];
pipe(fds);
close(fds[0]); // close the read end
ssize_t n = write(fds[1], "hello", 5);
printf("write returned %zd\n", n);
return 0;
}17 of 53 in Operating Systems