I have a simple piece of code that periodically writes data to a fd that\'s passed to it. The fd will most likely be a pipe or socket but could potentially be anything. I can de
struct pollfd pfd = {.fd = yourfd, .events = POLLERR}; if (poll(&pfd, 1, whatever) < 0) abort(); if (pfd.revents & POLLERR) printf("pipe is broken\n");
This does work for me. Note that sockets are not exactly pipes and thus show different behavior (-> use POLLRDHUP).