summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL14
-rw-r--r--README2
-rw-r--r--src/biruda.c28
3 files changed, 42 insertions, 2 deletions
diff --git a/INSTALL b/INSTALL
index f302346..6664408 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,3 +1,17 @@
+Building on Linux
+-----------------
+
+Archlinux
+---------
+
+Install the following packages from the official repos or build them
+from the AUR:
+ * gengetopt
+ * confuse
+ * nanomsg
+ * json-c
+ * libdaemon
+
Building on Windows
-------------------
diff --git a/README b/README
index 132f1e0..4b02c16 100644
--- a/README
+++ b/README
@@ -29,6 +29,8 @@ Requirements
http://sourceware.org/pthreads-win32/
* json-c: JSON for message payload
https://github.com/json-c/json-c/wiki
+* libdaemon: for daemonizing support on Unix
+
Other projects
--------------
diff --git a/src/biruda.c b/src/biruda.c
index 6511812..d95530e 100644
--- a/src/biruda.c
+++ b/src/biruda.c
@@ -4,6 +4,7 @@
#ifndef _WIN32
#include <errno.h>
#include <unistd.h>
+#include <signal.h>
#endif
#include "biruda_cmdline.h"
@@ -146,6 +147,13 @@ static int create_coordinator( cfg_t *cfg )
return coordinator_init( control );
}
+static volatile int got_terminate = 0;
+
+static void terminate_foreground_func( int sig )
+{
+ got_terminate = 1;
+}
+
int main( int argc, char *argv[] )
{
struct gengetopt_args_info args_info;
@@ -194,8 +202,24 @@ int main( int argc, char *argv[] )
exit( EXIT_FAILURE );
}
}
-
- sleep( 10 );
+
+ if( args_info.foreground_given ) {
+#ifdef _WIN32
+#else
+ struct sigaction sa;
+
+ memset( &sa, 0, sizeof( struct sigaction ) );
+ sa.sa_handler = terminate_foreground_func;
+ sa.sa_flags = SA_RESTART;
+
+ (void)sigaction( SIGINT, &sa, NULL );
+ (void)sigaction( SIGTERM, &sa, NULL );
+
+ while( !got_terminate ) {
+ sleep( 1 );
+ }
+#endif
+ }
if( has_coordinator ) {
coordinator_terminate( );