[Cherokee-commits] rev 1244 - in cherokee/branches/0.6
cherokee at cherokee-project.com
cherokee at cherokee-project.com
Wed Mar 12 14:26:27 CET 2008
Author: alo
Date: 2008-03-12 14:26:27 +0100 (Wed, 12 Mar 2008)
New Revision: 1244
Log:
Get the changeset with:
svn diff -r 1243:1244 svn://svn.cherokee-project.com/
Modified:
cherokee/branches/0.6/ChangeLog
4 +
cherokee/branches/0.6/cherokee/main_guardian.c
64 ++++++++++++++-----------
Modified: cherokee/branches/0.6/ChangeLog
===================================================================
--- cherokee/branches/0.6/ChangeLog 2008-03-12 13:25:06 UTC (rev 1243)
+++ cherokee/branches/0.6/ChangeLog 2008-03-12 13:26:27 UTC (rev 1244)
@@ -1,5 +1,9 @@
2008-03-12 Alvaro Lopez Ortega <alvaro at alobbs.com>
+ * cherokee/main_guardian.: Signal management has changed. From now
+ on: SIGTERM kills the child and make guardian to exit; and SIGUSR1
+ restarts the child process.
+
* cherokee/main_guardian.c (process_launch): It had to check
whether -b was used, in which case it had to daemonize itself and
remove the parameter for argv.
Modified: cherokee/branches/0.6/cherokee/main_guardian.c
===================================================================
--- cherokee/branches/0.6/cherokee/main_guardian.c 2008-03-12 13:25:06 UTC (rev 1243)
+++ cherokee/branches/0.6/cherokee/main_guardian.c 2008-03-12 13:26:27 UTC (rev 1244)
@@ -41,21 +41,56 @@
static pid_t pid;
+static ret_t
+process_wait (pid_t pid)
+{
+ pid_t re;
+ int exitcode = 0;
+
+ re = waitpid (pid, &exitcode, 0);
+ if (re == -1)
+ return ret_error;
+
+ if (WIFEXITED(exitcode)) {
+ int re = WEXITSTATUS(exitcode);
+
+ /* Child terminated normally */
+ PRINT_MSG ("Server PID=%d exited re=%d\n", pid, re);
+ if (re != 0)
+ return ret_error;
+ }
+ else if (WIFSIGNALED(exitcode)) {
+ /* Child process terminated by a signal */
+ PRINT_MSG ("Server PID=%d received a signal=%d\n", pid, WTERMSIG(exitcode));
+ }
+
+ return ret_ok;
+}
+
+
static void
guardian_signals_handler (int sig, siginfo_t *si, void *context)
{
int exitcode;
switch (sig) {
- case SIGHUP:
+ case SIGUSR1:
/* Restart Cherokee */
kill (pid, SIGINT);
+ process_wait (pid);
break;
case SIGCHLD:
/* Child exited */
wait (&exitcode);
break;
+
+ case SIGTERM:
+ /* Kill child and exit */
+ kill (pid, SIGTERM);
+ process_wait (pid);
+ exit(0);
+
default:
/* Forward the signal */
kill (pid, sig);
@@ -74,7 +109,6 @@
act.sa_handler = SIG_IGN;
sigaction (SIGPIPE, &act, NULL);
- sigaction (SIGUSR1, &act, NULL);
/* Signals it handles
*/
@@ -85,6 +119,7 @@
sigaction (SIGHUP, &act, NULL);
sigaction (SIGSEGV, &act, NULL);
sigaction (SIGTERM, &act, NULL);
+ sigaction (SIGUSR1, &act, NULL);
}
static pid_t
@@ -123,32 +158,7 @@
return pid;
}
-static ret_t
-process_wait (pid_t pid)
-{
- pid_t re;
- int exitcode = 0;
- re = waitpid (pid, &exitcode, 0);
- if (re == -1)
- return ret_error;
-
- if (WIFEXITED(exitcode)) {
- int re = WEXITSTATUS(exitcode);
-
- /* Child terminated normally */
- PRINT_MSG ("Server PID=%d exited re=%d\n", pid, re);
- if (re != 0)
- return ret_error;
- }
- else if (WIFSIGNALED(exitcode)) {
- /* Child process terminated by a signal */
- PRINT_MSG ("Server PID=%d received a signal=%d\n", pid, WTERMSIG(exitcode));
- }
-
- return ret_ok;
-}
-
static void
save_pid_file (int pid)
{
More information about the Cherokee-commits
mailing list