Implemented exec_config
This commit is contained in:
parent
b6c816b3bb
commit
3ff396db6a
1 changed files with 19 additions and 0 deletions
|
@ -6,9 +6,11 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
static void exec_config(const char *path);
|
||||||
static void sig_handler(int sig);
|
static void sig_handler(int sig);
|
||||||
|
|
||||||
int g_is_about_to_quit = 0;
|
int g_is_about_to_quit = 0;
|
||||||
|
@ -19,6 +21,8 @@ main(int argc, char *argv[])
|
||||||
char config_path[PATH_MAX];
|
char config_path[PATH_MAX];
|
||||||
int option;
|
int option;
|
||||||
|
|
||||||
|
argv0 = argv[0];
|
||||||
|
|
||||||
config_path[0] = '\0';
|
config_path[0] = '\0';
|
||||||
|
|
||||||
while ((option = getopt(argc, argv, "hvc:")) != -1) {
|
while ((option = getopt(argc, argv, "hvc:")) != -1) {
|
||||||
|
@ -63,6 +67,21 @@ main(int argc, char *argv[])
|
||||||
signal(SIGTERM, sig_handler);
|
signal(SIGTERM, sig_handler);
|
||||||
signal(SIGCHLD, sig_handler);
|
signal(SIGCHLD, sig_handler);
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
|
exec_config(config_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
exec_config(const char *path)
|
||||||
|
{
|
||||||
|
switch(fork()) {
|
||||||
|
case -1:
|
||||||
|
warn("failed to execute config\n");
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
execl(path, path, NULL);
|
||||||
|
die("failed to execute config\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Reference in a new issue