diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-10-21 10:20:44 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-10-21 10:20:44 +0200 |
commit | 5f11a9e4ae70e091557f992dcc4f0bb87ea698ec (patch) | |
tree | 9066e14df99c522bd5899a56304ed436feec3f77 /src | |
parent | 8b5641263a915d4b8ac4c9c8f84f34f09b120402 (diff) | |
download | pa-sink-ctl-5f11a9e4ae70e091557f992dcc4f0bb87ea698ec.tar.gz pa-sink-ctl-5f11a9e4ae70e091557f992dcc4f0bb87ea698ec.tar.bz2 pa-sink-ctl-5f11a9e4ae70e091557f992dcc4f0bb87ea698ec.zip |
signalfd: Read out received signals
Diffstat (limited to 'src')
-rw-r--r-- | src/interface.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/interface.c b/src/interface.c index 74a04d3..385e5d9 100644 --- a/src/interface.c +++ b/src/interface.c @@ -364,6 +364,15 @@ interface_set_status(const gchar *msg) static gboolean resize_gio(GIOChannel *source, GIOCondition condition, gpointer data) { + struct signalfd_siginfo fdsi; + ssize_t s; + + g_assert(condition & G_IO_IN); + + s = read(signal_fd, &fdsi, sizeof fdsi); + if (s != sizeof fdsi || fdsi.ssi_signo != SIGWINCH) + return FALSE; + return interface_resize(data); } #endif @@ -403,6 +412,8 @@ interface_init(void) sigemptyset(&mask); sigaddset(&mask, SIGWINCH); + if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) + exit(EXIT_FAILURE); signal_fd = signalfd(-1, &mask, 0); channel = g_io_channel_unix_new(signal_fd); g_io_add_watch(channel, G_IO_IN, resize_gio, NULL); |