X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fmain.c;h=f03b959f68998500a36e282f05d85a10536befb7;hb=68fb08920b2162b48cf0fa8dd98b021327b42896;hp=6656cb4ef093bb6499f918bcf7db13d436e9ba48;hpb=9543ad166338a7bef8718070f11465df4b9badd7;p=elogind.git diff --git a/src/main.c b/src/main.c index 6656cb4ef..f03b959f6 100644 --- a/src/main.c +++ b/src/main.c @@ -6,16 +6,16 @@ Copyright 2010 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -1631,6 +1631,11 @@ finish: assert(i <= ELEMENTSOF(args)); + /* Close and disarm the watchdog, so that the new + * instance can reinitialize it, but doesn't get + * rebooted while we do that */ + watchdog_close(true); + execv(args[0], (char* const*) args); log_error("Failed to reexecute: %m"); @@ -1643,19 +1648,16 @@ finish: fdset_free(fds); if (shutdown_verb) { - char e[32]; - const char * command_line[] = { SYSTEMD_SHUTDOWN_BINARY_PATH, shutdown_verb, NULL }; - const char * env_block[] = { - NULL, - NULL - }; + char **env_block; if (arm_reboot_watchdog && arg_shutdown_watchdog > 0) { + char e[32]; + /* If we reboot let's set the shutdown * watchdog and tell the shutdown binary to * repeatedly ping it */ @@ -1665,11 +1667,15 @@ finish: /* Tell the binary how often to ping */ snprintf(e, sizeof(e), "WATCHDOG_USEC=%llu", (unsigned long long) arg_shutdown_watchdog); char_array_0(e); - env_block[0] = e; - } else + + env_block = strv_append(environ, e); + } else { + env_block = strv_copy(environ); watchdog_close(true); + } - execve(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line, (char**) env_block); + execve(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line, env_block); + free(env_block); log_error("Failed to execute shutdown binary, freezing: %m"); }