Negative return value of printf() is not used when write() returns
a negative value, instead, SIGPIPE is sent.
#include <glob.h>
#include <dirent.h>
#include <getopt.h>
#include <glob.h>
#include <dirent.h>
#include <getopt.h>
+/*
+ * 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];
int main(int argc, char *argv[]) {
char part[512],
pathbuf[512];
+ 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)
SIMPLEQ_INIT(&batteries);
while ((o = getopt_long(argc, argv, "c:h", long_options, &option_index)) != -1)