freebsd-ports/sysutils/inotify-tools/files/patch-src_inotifywatch.c
Mark Felder ec0d7fe6c2 sysutils/inotify-tools: Update to 3.14.01
This update prevents signal handling from being blocked on a worker
thread as well as an accumulation of other bug fixes.

PR:		204366
MFH:		2016Q1
2016-03-15 16:58:12 +00:00

50 lines
1.2 KiB
C

--- src/inotifywatch.c.orig 2015-11-09 01:40:46 UTC
+++ src/inotifywatch.c
@@ -12,6 +12,9 @@
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
+#ifdef __FreeBSD__
+#include <pthread.h>
+#endif // __FreeBSD__
#include <regex.h>
#include <signal.h>
#include <stdbool.h>
@@ -93,6 +96,9 @@ int main(int argc, char ** argv)
char * exc_iregex = NULL;
char * inc_regex = NULL;
char * inc_iregex = NULL;
+#ifdef __FreeBSD__
+ sigset_t set, oset;
+#endif // __FreeBSD__
signal( SIGINT, handle_impatient_user );
@@ -121,11 +127,27 @@ int main(int argc, char ** argv)
return EXIT_FAILURE;
}
+#ifdef __FreeBSD__
+ // Block some signals in libinotify's worker thread, so that
+ // handle_signal runs in the context of the main thread and
+ // the 'done' flag is actually honored.
+ sigemptyset(&set);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGHUP);
+ sigaddset(&set, SIGTERM);
+ sigaddset(&set, SIGALRM);
+ pthread_sigmask(SIG_BLOCK, &set, &oset);
+#endif // __FreeBSD__
+
if ( !inotifytools_initialize() ) {
warn_inotify_init_error();
return EXIT_FAILURE;
}
+#ifdef __FreeBSD__
+ pthread_sigmask(SIG_SETMASK, &oset, NULL);
+#endif // __FreeBSD__
+
// Attempt to watch file
// If events is still 0, make it all events.
if ( !events )