Reorganize libutils and cleanups

This commit is contained in:
topjohnwu
2018-10-12 21:46:09 -04:00
parent d5a56d9e85
commit a9121fa28f
7 changed files with 128 additions and 147 deletions

View File

@@ -29,6 +29,8 @@
#include "pts.h"
#include "flags.h"
#define quit_signals ((int []) { SIGALRM, SIGABRT, SIGHUP, SIGPIPE, SIGQUIT, SIGTERM, SIGINT, 0 })
static void usage(int status) {
FILE *stream = (status == EXIT_SUCCESS) ? stdout : stderr;
@@ -84,6 +86,15 @@ static void sighandler(int sig) {
}
}
static void setup_sighandlers(void (*handler)(int)) {
struct sigaction act;
memset(&act, 0, sizeof(act));
act.sa_handler = handler;
for (int i = 0; quit_signals[i]; ++i) {
sigaction(quit_signals[i], &act, NULL);
}
}
/*
* Connect daemon, send argc, argv, cwd, pts slave
*/