diff options
author | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2009-10-21 11:14:02 +0000 |
---|---|---|
committer | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2009-10-21 11:14:02 +0000 |
commit | 7410d3c6d6a9a1cd7aa55083c938946af6ff9498 (patch) | |
tree | 3291beffa55649f9be28b4a98a7d503d334fbcf2 /src/starter/starter.c | |
parent | 41787e147279ff0695e9d759487266a60b80867b (diff) | |
download | vyos-strongswan-7410d3c6d6a9a1cd7aa55083c938946af6ff9498.tar.gz vyos-strongswan-7410d3c6d6a9a1cd7aa55083c938946af6ff9498.zip |
[svn-upgrade] Integrating new upstream version, strongswan (4.3.4)
Diffstat (limited to 'src/starter/starter.c')
-rw-r--r-- | src/starter/starter.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/src/starter/starter.c b/src/starter/starter.c index 2d2f452b5..b675ccf1c 100644 --- a/src/starter/starter.c +++ b/src/starter/starter.c @@ -66,46 +66,66 @@ static unsigned int _action_ = 0; -static void -fsig(int signal) +static void fsig(int signal) { switch (signal) { case SIGCHLD: { - int status; + int status, exit_status = 0; pid_t pid; char *name = NULL; while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { if (pid == starter_pluto_pid()) + { name = " (Pluto)"; + } if (pid == starter_charon_pid()) + { name = " (Charon)"; + } if (WIFSIGNALED(status)) + { DBG(DBG_CONTROL, DBG_log("child %d%s has been killed by sig %d\n", pid, name?name:"", WTERMSIG(status)) ) + } else if (WIFSTOPPED(status)) + { DBG(DBG_CONTROL, DBG_log("child %d%s has been stopped by sig %d\n", pid, name?name:"", WSTOPSIG(status)) ) + } else if (WIFEXITED(status)) + { + exit_status = WEXITSTATUS(status); + if (exit_status >= SS_RC_FIRST && exit_status <= SS_RC_LAST) + { + _action_ = FLAG_ACTION_QUIT; + } DBG(DBG_CONTROL, DBG_log("child %d%s has quit (exit code %d)\n", - pid, name?name:"", WEXITSTATUS(status)) + pid, name?name:"", exit_status) ) + } else + { DBG(DBG_CONTROL, DBG_log("child %d%s has quit", pid, name?name:"") ) + } if (pid == starter_pluto_pid()) - starter_pluto_sigchild(pid); + { + starter_pluto_sigchild(pid, exit_status); + } if (pid == starter_charon_pid()) - starter_charon_sigchild(pid); + { + starter_charon_sigchild(pid, exit_status); + } } } break; @@ -196,8 +216,7 @@ static void generate_selfcert() } } -static void -usage(char *name) +static void usage(char *name) { fprintf(stderr, "Usage: starter [--nofork] [--auto-update <sec>] " "[--debug|--debug-more|--debug-all]\n"); @@ -392,9 +411,13 @@ int main (int argc, char **argv) if (_action_ & FLAG_ACTION_QUIT) { if (starter_pluto_pid()) + { starter_stop_pluto(); + } if (starter_charon_pid()) + { starter_stop_charon(); + } starter_netkey_cleanup(); confread_free(cfg); unlink(STARTER_PID_FILE); |