wmbiff: Fix wmbiff restart.

This commit is contained in:
Gabriel VLASIU 2013-04-04 15:54:05 +03:00 committed by Carlos R. Mafra
parent ef01fb39db
commit 75ad28585c

View file

@ -963,12 +963,16 @@ static void restart_wmbiff(int sig
#endif #endif
) )
{ {
DMA(DEBUG_ERROR, "exec()'ing %s\n", restart_args[0]); if (restart_args) {
sleep(1); DMA(DEBUG_ERROR, "exec()'ing %s\n", restart_args[0]);
execvp(restart_args[0], (char *const *) restart_args); sleep(1);
DMA(DEBUG_ERROR, "exec of %s failed: %s\n", execvp(restart_args[0], (char *const *) restart_args);
restart_args[0], strerror(errno)); DMA(DEBUG_ERROR, "exec of %s failed: %s\n",
exit(EXIT_FAILURE); restart_args[0], strerror(errno));
exit(EXIT_FAILURE);
}
else
fprintf(stderr, "Unable to restart wmbiff: missing restart arguments (NULL)!\n");
} }
extern int x_socket(void) extern int x_socket(void)
@ -1367,8 +1371,10 @@ int main(int argc, const char *argv[])
will need them if we have to restart on sigusr1 */ will need them if we have to restart on sigusr1 */
restart_args = restart_args =
(const char **) malloc((argc + 1) * sizeof(const char *)); (const char **) malloc((argc + 1) * sizeof(const char *));
memcpy(restart_args, argv, (argc) * sizeof(const char *)); if (restart_args) {
restart_args[argc] = NULL; memcpy(restart_args, argv, (argc) * sizeof(const char *));
restart_args[argc] = NULL;
}
parse_cmd(argc, argv, uconfig_file); parse_cmd(argc, argv, uconfig_file);
@ -1397,5 +1403,10 @@ int main(int argc, const char *argv[])
signal(SIGPIPE, SIG_IGN); /* write() may fail */ signal(SIGPIPE, SIG_IGN); /* write() may fail */
do_biff(argc, argv); do_biff(argc, argv);
// free resources
if (restart_args)
free(restart_args);
return 0; return 0;
} }