summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-20 00:12:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-20 00:12:51 +0000
commite1aec4aed8e745c41ab36ad8914285f011cd8b4f (patch)
treed1209d4c143391f5a639e399d2bbce63a7ae4d01 /process.c
parent56f2d0aa98e2cbddf20d8c382d4ee824ebd3a4f2 (diff)
* process.c (rb_fork): flush stdouts always before fork(2).
fixed: [ruby-dev:30612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/process.c b/process.c
index 98a65b0433..c6caf5f7f2 100644
--- a/process.c
+++ b/process.c
@@ -1343,10 +1343,16 @@ rb_fork(int *status, int (*chfunc)(void*), void *charg)
#endif
#ifndef __VMS
- rb_io_flush(rb_stdout);
- rb_io_flush(rb_stderr);
+#define prefork() ( \
+ rb_io_flush(rb_stdout), \
+ rb_io_flush(rb_stderr) \
+ )
+#else
+#define prefork() ((void)0)
#endif
+ prefork();
+
#ifdef FD_CLOEXEC
if (chfunc) {
if (pipe(ep)) return -1;
@@ -1356,7 +1362,7 @@ rb_fork(int *status, int (*chfunc)(void*), void *charg)
}
}
#endif
- while ((pid = fork()) < 0) {
+ for (; (pid = fork()) < 0; prefork()) {
switch (errno) {
case EAGAIN:
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN