diff options
Diffstat (limited to 'accel-pppd/extra')
-rw-r--r-- | accel-pppd/extra/pppd_compat.c | 48 | ||||
-rw-r--r-- | accel-pppd/extra/sigchld.c | 2 |
2 files changed, 32 insertions, 18 deletions
diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c index f897dd68..66f54535 100644 --- a/accel-pppd/extra/pppd_compat.c +++ b/accel-pppd/extra/pppd_compat.c @@ -159,6 +159,10 @@ static void ev_ppp_pre_up(struct ppp_t *ppp) return; } } else if (pid == 0) { + sigset_t set; + sigfillset(&set); + pthread_sigmask(SIG_UNBLOCK, &set, NULL); + execve(conf_ip_pre_up, argv, env); log_emerg("pppd_compat: exec '%s': %s\n", conf_ip_pre_up, strerror(errno)); _exit(EXIT_FAILURE); @@ -198,6 +202,10 @@ static void ev_ppp_started(struct ppp_t *ppp) log_ppp_info2("pppd_compat: ip-up started (pid %i)\n", pid); sigchld_unlock(); } else if (pid == 0) { + sigset_t set; + sigfillset(&set); + pthread_sigmask(SIG_UNBLOCK, &set, NULL); + execve(conf_ip_up, argv, env); log_emerg("pppd_compat: exec '%s': %s\n", conf_ip_up, strerror(errno)); _exit(EXIT_FAILURE); @@ -266,23 +274,29 @@ static void ev_ppp_finished(struct ppp_t *ppp) env[4] = NULL; fill_env(env, pd); - sigchld_lock(); - pid = fork(); - if (pid > 0) { - pd->ip_down_hnd.pid = pid; - sigchld_register_handler(&pd->ip_down_hnd); - if (conf_verbose) - log_ppp_info2("pppd_compat: ip-down started (pid %i)\n", pid); - sigchld_unlock(); - triton_context_schedule(); - pthread_mutex_lock(&pd->ip_down_hnd.lock); - pthread_mutex_unlock(&pd->ip_down_hnd.lock); - } else if (pid == 0) { - execve(conf_ip_down, argv, env); - log_emerg("pppd_compat: exec '%s': %s\n", conf_ip_down, strerror(errno)); - _exit(EXIT_FAILURE); - } else - log_error("pppd_compat: fork: %s\n", strerror(errno)); + if (conf_ip_down) { + sigchld_lock(); + pid = fork(); + if (pid > 0) { + pd->ip_down_hnd.pid = pid; + sigchld_register_handler(&pd->ip_down_hnd); + if (conf_verbose) + log_ppp_info2("pppd_compat: ip-down started (pid %i)\n", pid); + sigchld_unlock(); + triton_context_schedule(); + pthread_mutex_lock(&pd->ip_down_hnd.lock); + pthread_mutex_unlock(&pd->ip_down_hnd.lock); + } else if (pid == 0) { + sigset_t set; + sigfillset(&set); + pthread_sigmask(SIG_UNBLOCK, &set, NULL); + + execve(conf_ip_down, argv, env); + log_emerg("pppd_compat: exec '%s': %s\n", conf_ip_down, strerror(errno)); + _exit(EXIT_FAILURE); + } else + log_error("pppd_compat: fork: %s\n", strerror(errno)); + } pthread_mutex_lock(&pd->ip_up_hnd.lock); if (pd->ip_up_hnd.pid) { diff --git a/accel-pppd/extra/sigchld.c b/accel-pppd/extra/sigchld.c index abfd42f1..08bab93d 100644 --- a/accel-pppd/extra/sigchld.c +++ b/accel-pppd/extra/sigchld.c @@ -35,7 +35,7 @@ static void* sigchld_thread(void *arg) sigaddset(&set, SIGQUIT); while (1) { - pid = waitpid(0, &status, 0); + pid = waitpid(-1, &status, 0); if (pid < 0) { if (errno == EINTR) continue; |