restart even after normal termination

This commit is contained in:
David Rose 2002-10-21 21:05:59 +00:00
parent e6d6f3d529
commit 999fc0c6b4
1 changed files with 8 additions and 3 deletions

View File

@ -38,6 +38,7 @@
char **params = NULL;
char *logfile_name = NULL;
int logfile_fd = -1;
int stop_on_terminate = 0;
pid_t child_pid = 0;
@ -104,13 +105,13 @@ spawn_process() {
fprintf(stderr, "\nprocess caught signal %d.\n\n", signal);
/* A signal exit is a reason to respawn unless the signal is TERM
or KILL. */
return (signal != SIGTERM && signal != SIGKILL);
return !stop_on_terminate || (signal != SIGTERM && signal != SIGKILL);
} else {
int exit_status = WEXITSTATUS(status);
fprintf(stderr, "\nprocess exited with status %d.\n\n", WEXITSTATUS(status));
/* Normal exit is a reason to respawn if the status indicates failure. */
return (exit_status != 0);
return !stop_on_terminate || (exit_status != 0);
}
}
@ -287,7 +288,7 @@ main(int argc, char *argv[]) {
extern char *optarg;
extern int optind;
/* The initial '+' instructs GNU getopt not to reorder switches. */
static const char *optflags = "+l:h";
static const char *optflags = "+l:th";
int flag;
flag = getopt(argc, argv, optflags);
@ -297,6 +298,10 @@ main(int argc, char *argv[]) {
logfile_name = optarg;
break;
case 't':
stop_on_terminate = 1;
break;
case 'h':
help();
return 1;