Permalink
Browse files

builtin_client: registered event exception handler

Signed-off-by: Daniel Borkmann <borkmann@iogearbox.net>
  • Loading branch information...
1 parent 1d913a9 commit 413a28cd3118619150d98f40705cc58dce435abf @borkmann borkmann committed Apr 25, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 linux/tools/sensord/builtin_client.c
@@ -7,17 +7,37 @@
#include <sys/un.h>
#include <unistd.h>
#include <stdio.h>
+#include <signal.h>
#include "xutils.h"
#define SOCK_ADDR "sensordsock"
+static void upper_threshold_triggered(int num)
+{
+ if (num != SIGUSR1)
+ return;
+
+ printf("ALERT: upper threshold triggered!\n");
+}
+
+static void lower_threshold_triggered(int num)
+{
+ if (num != SIGUSR2)
+ return;
+
+ printf("ALERT: lower threshold triggered!\n");
+}
+
int main(void)
{
int sock, ret;
struct sockaddr_un saddr;
socklen_t slen;
+ signal(SIGUSR1, upper_threshold_triggered);
+ signal(SIGUSR2, lower_threshold_triggered);
+
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0)
panic("Cannot create socket!\n");

0 comments on commit 413a28c

Please sign in to comment.