aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/unix/sys.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2014-01-10 18:37:10 +0100
committerLukas Larsson <[email protected]>2014-01-10 18:37:10 +0100
commitac4868020599cd8093cd6f5cc7a8ec61a86a5941 (patch)
treec1f0f9a2a4a8c651c71b2103bc99eed3235d9ccf /erts/emulator/sys/unix/sys.c
parent039ea3a6ed5dc147478f294910ba042850db2383 (diff)
parentb9eb22b7cdb7c52b87848c486214012aabf8cf96 (diff)
downloadotp-ac4868020599cd8093cd6f5cc7a8ec61a86a5941.tar.gz
otp-ac4868020599cd8093cd6f5cc7a8ec61a86a5941.tar.bz2
otp-ac4868020599cd8093cd6f5cc7a8ec61a86a5941.zip
Merge branch 'lukas/erts/fd0_pipe_bug/OTP-11558'
* lukas/erts/fd0_pipe_bug/OTP-11558: erts: Make sure fds 0,1 and 2 are open
Diffstat (limited to 'erts/emulator/sys/unix/sys.c')
-rw-r--r--erts/emulator/sys/unix/sys.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index 61f9f6a59a..59e34eb819 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
@@ -547,6 +547,25 @@ erts_sys_pre_init(void)
#endif
#endif /* USE_THREADS */
erts_smp_atomic_init_nob(&sys_misc_mem_sz, 0);
+
+ {
+ /*
+ * Unfortunately we depend on fd 0,1,2 in the old shell code.
+ * So if for some reason we do not have those open when we start
+ * we have to open them here. Not doing this can cause the emulator
+ * to deadlock when reaping the fd_driver ports :(
+ */
+ int fd;
+ /* Make sure fd 0 is open */
+ if ((fd = open("/dev/null", O_RDONLY)) != 0)
+ close(fd);
+ /* Make sure fds 1 and 2 are open */
+ while (fd < 3) {
+ fd = open("/dev/null", O_WRONLY);
+ }
+ close(fd);
+ }
+
}
void