X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=i3status.c;h=bec4c81bef10f38e21d7ed0c09b713cd66d113bc;hb=refs%2Ftags%2F1.2;hp=fd781cb344423f5a3db5ae96850dfe08ad514c20;hpb=1dfe4aeff38b2ab988cb3038311e49bb58aff306;p=i3%2Fi3status diff --git a/i3status.c b/i3status.c index fd781cb..bec4c81 100644 --- a/i3status.c +++ b/i3status.c @@ -54,6 +54,7 @@ #include #include #include +#include #include "queue.h" @@ -693,6 +694,16 @@ static int load_configuration(const char *configfile) { return result; } +/* + * Exit upon SIGPIPE because when we have nowhere to write to, gathering + * system information is pointless. + * + */ +void sigpipe(int signum) { + fprintf(stderr, "Received SIGPIPE, exiting\n"); + exit(1); +} + int main(int argc, char *argv[]) { char part[512], pathbuf[512]; @@ -706,6 +717,11 @@ int main(int argc, char *argv[]) { {0, 0, 0, 0} }; + struct sigaction action; + memset(&action, 0, sizeof(struct sigaction)); + action.sa_handler = sigpipe; + sigaction(SIGPIPE, &action, NULL); + SIMPLEQ_INIT(&batteries); while ((o = getopt_long(argc, argv, "c:h", long_options, &option_index)) != -1)