From f92438d42a7b1c4d40471ccad403a7fa7d941730 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Wed, 14 Jul 2010 18:09:16 -0300 Subject: [PATCH] Add hook to call shutdown script Signed-off-by: Claudio Matsuoka --- finit-alt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/finit-alt.c b/finit-alt.c index 92904d55..29f5e08e 100644 --- a/finit-alt.c +++ b/finit-alt.c @@ -127,7 +127,7 @@ void signal_handler(int); void chld_handler(int); static int debug = 0; - +static char sdown[CMD_SIZE]; static void build_cmd(char *cmd, char *x, int len) { @@ -293,6 +293,11 @@ int main() build_cmd(hostname, x, HOSTNAME_SIZE); continue; } + if (MATCH_CMD(line, "shutdown ", x)) { + *sdown = 0; + build_cmd(sdown, x, CMD_SIZE); + continue; + } if (MATCH_CMD(line, "module ", x)) { strcpy(cmd, "/sbin/modprobe "); build_cmd(cmd, x, CMD_SIZE); @@ -574,6 +579,9 @@ int main() void shutdown(int sig) { touch("/tmp/shutdown"); + if (sdown) { + system(sdown); + } kill(-1, SIGTERM);