aboutsummaryrefslogtreecommitdiffstats
path: root/src/redshift.c
diff options
context:
space:
mode:
authorJon Lund Steffensen <jonlst@gmail.com>2014-12-28 19:26:29 -0500
committerJon Lund Steffensen <jonlst@gmail.com>2014-12-28 19:26:29 -0500
commit59023d86f4275128751bcb84ecda5a630bf51857 (patch)
treeff9f17eba3bdfec0fac22332e1689a93b33209bb /src/redshift.c
parentREADME: Add flattr button at the end (diff)
parentredshift.1: Add description of hooks in man page (diff)
downloadredshift-ng-59023d86f4275128751bcb84ecda5a630bf51857.tar.gz
redshift-ng-59023d86f4275128751bcb84ecda5a630bf51857.tar.bz2
redshift-ng-59023d86f4275128751bcb84ecda5a630bf51857.tar.xz
Merge branch 'hooks-dir'
Diffstat (limited to 'src/redshift.c')
-rw-r--r--src/redshift.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/redshift.c b/src/redshift.c
index 60cd9f5..429ae38 100644
--- a/src/redshift.c
+++ b/src/redshift.c
@@ -47,6 +47,7 @@
#include "config-ini.h"
#include "solar.h"
#include "systemtime.h"
+#include "hooks.h"
#define MIN(x,y) ((x) < (y) ? (x) : (y))
@@ -296,14 +297,6 @@ typedef enum {
PROGRAM_MODE_MANUAL
} program_mode_t;
-/* Periods of day. */
-typedef enum {
- PERIOD_NONE = 0,
- PERIOD_DAYTIME,
- PERIOD_NIGHT,
- PERIOD_TRANSITION
-} period_t;
-
/* Names of periods of day */
static const char *period_names[] = {
/* TRANSLATORS: Name printed when period of day is unknown */
@@ -1445,6 +1438,18 @@ main(int argc, char *argv[])
perror("sigaction");
exit(EXIT_FAILURE);
}
+
+ /* Ignore CHLD signal. This causes child processes
+ (hooks) to be reaped automatically. */
+ sigact.sa_handler = SIG_IGN;
+ sigact.sa_mask = sigset;
+ sigact.sa_flags = 0;
+
+ r = sigaction(SIGCHLD, &sigact, NULL);
+ if (r < 0) {
+ perror("sigaction");
+ exit(EXIT_FAILURE);
+ }
#endif /* HAVE_SIGNAL_H && ! __WIN32__ */
if (verbose) {
@@ -1540,6 +1545,12 @@ main(int argc, char *argv[])
print_period(period, transition);
}
+ /* Activate hooks if period changed */
+ if (period != prev_period) {
+ hooks_signal_period_change(prev_period,
+ period);
+ }
+
/* Ongoing short transition */
if (short_trans_delta) {
/* Calculate alpha */