aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2013-11-24 11:12:10 +0200
committerSergey Poznyakoff <gray@gnu.org>2013-11-24 11:12:10 +0200
commit672107ba3993937551ef930b1ad8350569ce6d7d (patch)
treeaa884e7c8883f4d415a7a02806062be126a56e7b
parent81c6e94f238233975c9e30149cfbebbff929e8cd (diff)
downloadjumper-672107ba3993937551ef930b1ad8350569ce6d7d.tar.gz
jumper-672107ba3993937551ef930b1ad8350569ce6d7d.tar.bz2
Improve process termination sequence.
* src/progman.c (shutdown_timeout): New global. (proc_kill): Output the process type in the debug diagnostics. (progman_terminate): Keep redirectors running until their master processes finish or shutdown timeout expires. * src/jumper.h (shutdown_timeout): New extern. * src/config.c: New global configuration statement: shutdown-timeout * doc/jumper.8in: Document the shutdown-timeout statement.
-rw-r--r--doc/jumper.8in9
-rw-r--r--src/config.c2
-rw-r--r--src/jumper.h1
-rw-r--r--src/progman.c25
4 files changed, 33 insertions, 4 deletions
diff --git a/doc/jumper.8in b/doc/jumper.8in
index df2a230..e96570c 100644
--- a/doc/jumper.8in
+++ b/doc/jumper.8in
@@ -14,7 +14,7 @@
.\" You should have received a copy of the GNU General Public License
.\" along with Jumper. If not, see <http://www.gnu.org/licenses/>.
.so config.so
-.TH JUMPER 8 "November 15, 2013" "JUMPER"
+.TH JUMPER 8 "November 24, 2013" "JUMPER"
.SH NAME
jumper \- bring up network links on demand
.SH SYNOPSIS
@@ -385,6 +385,13 @@ from the controlling terminal.
\fBdebug\fR \fINUMBER\fB;\fR
Set debugging level.
.TP
+\fBshutdown\-timeout\fR \fINUMBER\fB;\fR
+When \fBjumper\fR is terminated, it shuts down all subprocesses
+launched so far. This statement sets the time to wait for them
+to exit properly. If any processes are left after \fINUMBER\fR
+of seconds, \fBjumper\fR will terminate them forcefully, delivering
+them the \fBSIGKILL\fR signal. The default timeout is 15 seconds.
+.TP
\fBlisten\fR \fIIFACE\fR \fB{ ... }\fR
Listen on interface \fIIFACE\fR. The following instructions are
available for use in the \fB{ ... }\fR block:
diff --git a/src/config.c b/src/config.c
index be5dd21..f65dd00 100644
--- a/src/config.c
+++ b/src/config.c
@@ -707,6 +707,8 @@ static struct grecs_keyword jumper_kw[] = {
grecs_type_section, GRECS_DFLT, NULL, 0, NULL, NULL, syslog_kw },
{ "debug", "level", "Set debug level",
grecs_type_int, GRECS_DFLT, &debug_level },
+ { "shutdown-timeout", "seconds", "Set shutdown timeout",
+ grecs_type_uint, GRECS_DFLT, &shutdown_timeout },
{ "listen", "iface: string", "Configure listener",
grecs_type_section, GRECS_DFLT, NULL, 0,
cb_listen, NULL, listen_kw },
diff --git a/src/jumper.h b/src/jumper.h
index b98b2f7..0ccf427 100644
--- a/src/jumper.h
+++ b/src/jumper.h
@@ -48,6 +48,7 @@ extern int log_to_stderr;
extern int debug_level;
extern int foreground;
extern char *pidfile;
+extern unsigned shutdown_timeout;
void *emalloc(size_t size);
void *ecalloc(size_t nmemb, size_t size);
diff --git a/src/progman.c b/src/progman.c
index 4ccd583..ccbaccf 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -48,6 +48,22 @@ static struct process *proc_avail;
static unsigned proc_count; /* Total number of processes in proc_list */
int proc_stop; /* Number of terminated processes */
+
+unsigned shutdown_timeout = 15;
+
+static char *
+proc_type_str(int type)
+{
+ switch (type) {
+ case type_listener:
+ return "listener";
+ case type_redirector:
+ return "redirector";
+ case type_action:
+ return "action";
+ }
+ return "unknown";
+}
/* Basic functions for maintaining the proc_list */
static struct process *
@@ -213,7 +229,9 @@ proc_kill(listener_t *lp)
for (p = proc_list; p; p = p->next)
if (p->lp == lp && p->type != type_listener) {
- debug(1, ("killing pid %lu", (unsigned long) p->pid));
+ debug(1, ("killing pid %lu (%s)",
+ (unsigned long) p->pid,
+ proc_type_str(p->type)));
kill(p->pid, SIGKILL);
}
}
@@ -278,11 +296,12 @@ progman_terminate()
debug(1, ("sending running processes the TERM signal"));
for (p = proc_list; p; p = p->next)
- kill(p->pid, SIGTERM);
+ if (p->type != type_redirector)
+ kill(p->pid, SIGTERM);
start = time(NULL);
while (proc_list) {
- if (time(NULL) - start > 5) {
+ if (time(NULL) - start > shutdown_timeout) {
diag(LOG_NOTICE,
"sending running processes the KILL signal");
for (p = proc_list; p; p = p->next)

Return to:

Send suggestions and report system problems to the System administrator.