From d27d5d47f251a751fb82302eaab4b016696f3c0e Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 10 Oct 2002 22:00:50 +0000 Subject: [PATCH] cosmetic restructuring --- direct/src/autorestart/autorestart.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/direct/src/autorestart/autorestart.c b/direct/src/autorestart/autorestart.c index 129bf53208..3648529621 100644 --- a/direct/src/autorestart/autorestart.c +++ b/direct/src/autorestart/autorestart.c @@ -160,14 +160,20 @@ do_autorestart() { perror("sigaction"); } - - /* If we have a logfile, dup it onto stdout and stderr. */ if (logfile_fd >= 0) { + /* If we have a logfile, dup it onto stdout and stderr. */ dup2(logfile_fd, STDOUT_FILENO); dup2(logfile_fd, STDERR_FILENO); close(logfile_fd); + } else { + /* Otherwise, close them. */ + close(STDOUT_FILENO); + close(STDERR_FILENO); } + /* Make sure stdin is closed. */ + close(STDIN_FILENO); + now = time(NULL); strftime(time_buffer, TIME_BUFFER_SIZE, "%T on %A, %d %b %Y", localtime(&now)); fprintf(stderr, "autorestart begun at %s.\n", time_buffer); @@ -328,9 +334,6 @@ main(int argc, char *argv[]) { fprintf(stderr, "Generating output to %s.\n", logfile_name); } - /* Make sure standard input is closed. */ - close(STDIN_FILENO); - double_fork(); return 0;