mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-20 07:00:03 +01:00
darwin: Don't leave stdin/stdout closed
<rdar://problem/15609419>
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
(cherry picked from commit ad8111d7c9)
This commit is contained in:
parent
200f98894a
commit
3218c1433f
1 changed files with 11 additions and 2 deletions
13
os/osinit.c
13
os/osinit.c
|
|
@ -208,10 +208,18 @@ OsInit(void)
|
||||||
dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
|
dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(__CYGWIN__)
|
#if !defined(XQUARTZ) /* STDIN is already /dev/null and STDOUT/STDERR is managed by console_redirect.c */
|
||||||
|
# if defined(__APPLE__)
|
||||||
|
int devnullfd = open(devnull, O_RDWR, 0);
|
||||||
|
assert(devnullfd > 2);
|
||||||
|
|
||||||
|
dup2(devnullfd, STDIN_FILENO);
|
||||||
|
dup2(devnullfd, STDOUT_FILENO);
|
||||||
|
close(devnullfd);
|
||||||
|
# elif !defined(__CYGWIN__)
|
||||||
fclose(stdin);
|
fclose(stdin);
|
||||||
fclose(stdout);
|
fclose(stdout);
|
||||||
#endif
|
# endif
|
||||||
/*
|
/*
|
||||||
* If a write of zero bytes to stderr returns non-zero, i.e. -1,
|
* 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
|
* then writing to stderr failed, and we'll write somewhere else
|
||||||
|
|
@ -245,6 +253,7 @@ OsInit(void)
|
||||||
setlinebuf(stderr);
|
setlinebuf(stderr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif /* !XQUARTZ */
|
||||||
|
|
||||||
#if !defined(WIN32) || defined(__CYGWIN__)
|
#if !defined(WIN32) || defined(__CYGWIN__)
|
||||||
if (getpgrp() == 0)
|
if (getpgrp() == 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue