Commit feac0301 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Don't use SIGHUP, it fails if varnishtest is run under nohup(1)

We recognize only the most famous signals by name SIGTERM, SIGINT
and SIGKILL, if you want a special signal you will have to use "-15"
or whatever.

The primary reason for this is that there is still no portable API
for translating "SIGXXX" to an integer.

It used to be that bin/kill.c contained an array:

	const char *const sys_signame[NSIG] = {
		[0] =           "Signal 0",
		[SIGHUP] =      "HUP",
		[SIGINT] =      "INT",
		[SIGQUIT] =     "QUIT",
		[SIGILL] =      "ILL",
		[...]

BSD unix sensibly moved this into libc, to avoid duplicating
this all over the place, but Linux has not done that.

The right way to do this, would have been to have <signal.h>
contain a table:

	#ifdef SIGNAL_DOC(n,s,l)
	SIGNAL_DOC(1, "HUP", "Hangup")
	SIGNAL_DOC(2, "INT", "Interrupt")
	...
	#endif

That way nobody would ever need another #ifdef SIGFOO.

Anyway...

Rather than pointlessly add a semi-complete list of signals no
sensible person should ever use in a varnishtest (SIGWINCH anybody
?) we support the famous three by name, and the rest by number.
parent 918cd814
......@@ -16,7 +16,7 @@ delay 0.5
# stop
process p1 -stop
process p2 -close
process p3 -kill "HUP"
process p3 -kill "INT"
# wait
process p1 -wait
......
......@@ -247,7 +247,7 @@ process_run(struct process *p)
static void
process_kill(const struct process *p, const char *sig)
{
int j;
int j = 0;
CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC);
AN(sig);
......@@ -257,12 +257,14 @@ process_kill(const struct process *p, const char *sig)
if (!strcmp(sig, "TERM"))
j = SIGTERM;
else if (!strcmp(sig, "HUP"))
j = SIGHUP;
else if (!strcmp(sig, "INT"))
j = SIGINT;
else if (!strcmp(sig, "KILL"))
j = SIGKILL;
else if (*sig == '-')
j = strtoul(sig + 1, NULL, 10);
else
j = strtoul(sig, NULL, 10);
vtc_log(p->vl, 0, "Could not grok signal (%s)", sig);
if (kill(p->pid, j) < 0)
vtc_log(p->vl, 0, "Failed to send signal %d (%s)", j, strerror(errno));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment