Created
July 10, 2015 18:39
-
-
Save jpleau/783bfeb9fb59af9b3e01 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/io.c b/src/io.c | |
index f8813ed..f8095a5 100644 | |
--- a/src/io.c | |
+++ b/src/io.c | |
@@ -19,6 +19,12 @@ | |
#define _GNU_SOURCE /* for F_SETSIG */ | |
#include <fcntl.h> | |
+ | |
+#ifdef __FreeBSD__ | |
+#include <bsm/audit_fcntl.h> | |
+#define F_SETSIG BSM_F_SETSIG | |
+#endif | |
+ | |
#include <unistd.h> | |
#include "log.h" | |
diff --git a/src/sched.c b/src/sched.c | |
index d1c4634..0d02c01 100644 | |
--- a/src/sched.c | |
+++ b/src/sched.c | |
@@ -31,7 +31,7 @@ | |
#include "json.h" | |
#include "log.h" | |
-static sigset_t sigset; | |
+static sigset_t our_sigset; | |
static int | |
gcd(int a, int b) | |
@@ -88,13 +88,13 @@ setup_timer(struct bar *bar) | |
static int | |
setup_signals(void) | |
{ | |
- if (sigemptyset(&sigset) == -1) { | |
+ if (sigemptyset(&our_sigset) == -1) { | |
errorx("sigemptyset"); | |
return 1; | |
} | |
#define ADD_SIG(_sig) \ | |
- if (sigaddset(&sigset, _sig) == -1) { errorx("sigaddset(%d)", _sig); return 1; } | |
+ if (sigaddset(&our_sigset, _sig) == -1) { errorx("sigaddset(%d)", _sig); return 1; } | |
/* Control signals */ | |
ADD_SIG(SIGTERM); | |
@@ -125,7 +125,7 @@ setup_signals(void) | |
#undef ADD_SIG | |
/* Block signals for which we are interested in waiting */ | |
- if (sigprocmask(SIG_SETMASK, &sigset, NULL) == -1) { | |
+ if (sigprocmask(SIG_SETMASK, &our_sigset, NULL) == -1) { | |
errorx("sigprocmask"); | |
return 1; | |
} | |
@@ -164,7 +164,7 @@ sched_start(struct bar *bar) | |
bar_poll_timed(bar); | |
while (1) { | |
- sig = sigwaitinfo(&sigset, &siginfo); | |
+ sig = sigwaitinfo(&our_sigset, &siginfo); | |
if (sig == -1) { | |
/* Hiding the bar may interrupt this system call */ | |
if (errno == EINTR) | |
@@ -192,10 +192,12 @@ sched_start(struct bar *bar) | |
} else if (sig == SIGIO) { | |
bar_poll_clicked(bar); | |
+#ifndef __FreeBSD__ | |
/* Persistent block ready to be read? */ | |
} else if (sig == SIGRTMIN) { | |
bar_poll_readable(bar, siginfo.si_fd); | |
json_print_bar(bar); | |
+#endif | |
/* Blocks signaled? */ | |
} else if (sig > SIGRTMIN && sig <= SIGRTMAX) { | |
@@ -212,7 +214,7 @@ sched_start(struct bar *bar) | |
* Unblock signals (so subsequent syscall can be interrupted) | |
* and wait for child processes termination. | |
*/ | |
- if (sigprocmask(SIG_UNBLOCK, &sigset, NULL) == -1) | |
+ if (sigprocmask(SIG_UNBLOCK, &our_sigset, NULL) == -1) | |
errorx("sigprocmask"); | |
while (waitpid(-1, NULL, 0) > 0) | |
continue; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment