diff options
Diffstat (limited to 'xserver/os/osinit.c')
-rw-r--r-- | xserver/os/osinit.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/xserver/os/osinit.c b/xserver/os/osinit.c index f34b4363e..d4a94896c 100644 --- a/xserver/os/osinit.c +++ b/xserver/os/osinit.c @@ -222,33 +222,32 @@ OsInit(void) dup2(devnullfd, STDOUT_FILENO); close(devnullfd); # elif !defined(__CYGWIN__) - fclose(stdin); fclose(stdout); # endif - /* - * If a write of zero bytes to stderr returns non-zero, i.e. -1, - * then writing to stderr failed, and we'll write somewhere else - * instead. (Apparently this never happens in the Real World.) - */ - if (write (2, fname, 0) == -1) { - FILE *err; - - if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname) - snprintf (fname, sizeof(fname), ADMPATH, display); - else - strlcpy (fname, devnull, sizeof(fname)); - /* - * uses stdio to avoid os dependencies here, - * a real os would use - * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666) - */ - if (!(err = fopen (fname, "a+"))) - err = fopen (devnull, "w"); - if (err && (fileno(err) != 2)) { - dup2 (fileno (err), 2); - fclose (err); - } + /* + * If a write of zero bytes to stderr returns non-zero, i.e. -1, + * then writing to stderr failed, and we'll write somewhere else + * instead. (Apparently this never happens in the Real World.) + */ + if (write(2, fname, 0) == -1) { + FILE *err; + + if (strlen(display) + strlen(ADMPATH) + 1 < sizeof fname) + snprintf(fname, sizeof(fname), ADMPATH, display); + else + strlcpy(fname, devnull, sizeof(fname)); + /* + * uses stdio to avoid os dependencies here, + * a real os would use + * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666) + */ + if (!(err = fopen(fname, "a+"))) + err = fopen(devnull, "w"); + if (err && (fileno(err) != 2)) { + dup2(fileno(err), 2); + fclose(err); + } #if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN__) { static char buf[BUFSIZ]; |