summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-08 03:58:37 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-08 03:58:37 +0000
commitcbf33c59ded17f32783954a2226df63af9089504 (patch)
tree9351c61407b8f9ea61bbf99e9d55c8b82f3c4dd7 /process.c
parentab5865409e9a0392e990e0cda681aef3f8585da0 (diff)
merge revision(s) 26371,26373,26374,26972:
* eval.c (thread_timer, rb_thread_stop_timer): check the timing of stopping timer. patch from KOSAKI Motohiro <kosaki.motohiro _AT_ jp.fujitsu.com> * eval.c (rb_thread_start_timer): NetBSD5 seems to be hung when calling pthread_create() from pthread_atfork()'s parent handler. * io.c (pipe_open): workaround for NetBSD5. stop timer thread before fork(), and start it if needed. * process.c (rb_f_fork, rb_f_system): ditto. fixed [ruby-dev:40074] jp.fujitsu.com> via IRC. fork(), and restart it after fork() on parent, and on child if needed. these changes are tested by naruse. fixed [ruby-dev:40074] * io.c, eval.c, process.c: add linux to r26371's condition. patched by Motohiro KOSAKI [ruby-core:28151] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@28203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/process.c b/process.c
index 0d16bb6e43..c7be7286e1 100644
--- a/process.c
+++ b/process.c
@@ -1330,7 +1330,14 @@ rb_f_fork(obj)
fflush(stderr);
#endif
- switch (pid = fork()) {
+#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux)
+ before_exec();
+#endif
+ pid = fork();
+#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux)
+ after_exec();
+#endif
+ switch (pid) {
case 0:
#ifdef linux
after_exec();
@@ -1570,6 +1577,9 @@ rb_f_system(argc, argv)
chfunc = signal(SIGCHLD, SIG_DFL);
retry:
+#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux)
+ before_exec();
+#endif
pid = fork();
if (pid == 0) {
/* child process */
@@ -1577,6 +1587,9 @@ rb_f_system(argc, argv)
rb_protect(proc_exec_args, (VALUE)&earg, NULL);
_exit(127);
}
+#if defined(__NetBSD__) || defined(__APPLE__) || defined(linux)
+ after_exec();
+#endif
if (pid < 0) {
if (errno == EAGAIN) {
rb_thread_sleep(1);