Skip to content

Commit

Permalink
Set up the libev default loop
Browse files Browse the repository at this point in the history
We set up the libev default loop using just a simple signal handler that
waits for SIGINT so that a program can be exited neatly by stopping the
loop.
  • Loading branch information
digitalresistor committed Apr 20, 2012
1 parent 7f529fd commit 61ab58b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/dspawn.cc
Expand Up @@ -22,7 +22,13 @@
#include <sys/stat.h>
#include <dirent.h>

#include <ev++.h>

#include "version.h"
void signal_int(ev::sig& signal, int) {
signal.loop.break_loop();
}

int main(int argc, const char *argv[]) {
bool background = false;
unsigned int debug = 0;
Expand Down Expand Up @@ -94,5 +100,13 @@ int main(int argc, const char *argv[]) {

// Modify our umask
umask(0);
ev::default_loop loop;

ev::sig sig_int;
sig_int.set<signal_int>();
sig_int.start(SIGINT);

loop.run(0);

return 0;
}

0 comments on commit 61ab58b

Please sign in to comment.