don't die on SIGPIPE

this will allow `stint | sed q' to exit with a 0 return status, and also
to wait for the button to be released
master
Devin J. Pohly 11 years ago
parent d183e8d1a2
commit 8aa9308495

@ -1,3 +1,2 @@
* Would it be simpler to rewrite using XCB?
* Grab Esc to cancel?
* Handle EPIPE gracefully

@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <signal.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
@ -77,6 +78,10 @@ main(int argc, char *argv[])
goto out_ungrab;
}
// Don't die immediately if we get a SIGPIPE
struct sigaction sa_ign = { .sa_handler = SIG_IGN };
sigaction(SIGPIPE, &sa_ign, NULL);
// Print colors until Button1 is released
while (ev.type != ButtonRelease || ev.xbutton.button != 1) {
print_pixel(dpy, root, ev.xbutton.x_root, ev.xbutton.y_root);

Loading…
Cancel
Save