summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-22 00:39:04 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-22 00:39:04 +0000
commit5de33d8fa3804de75b60dd4fcbfebc626c7dac89 (patch)
treed72ee25cbfba24bab072f03daf4fb2289dfead0f /process.c
parent4357f31d2525fabc5b3b2ef0fea7fdf0e519da56 (diff)
* process.c (proc_exec_v, rb_proc_exec): preserve errno.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@13150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/process.c b/process.c
index 87fed73..624aeae 100644
--- a/process.c
+++ b/process.c
@@ -117,6 +117,9 @@ static VALUE S_Tms;
#endif
#endif
+#define preserving_errno(stmts) \
+ do {int saved_errno = errno; stmts; errno = saved_errno;} while (0)
+
/*
* call-seq:
@@ -990,7 +993,7 @@ proc_exec_v(argv, prog)
before_exec();
rb_thread_cancel_timer();
execv(prog, argv);
- after_exec();
+ preserving_errno(after_exec());
return -1;
}
@@ -1059,7 +1062,7 @@ rb_proc_exec(str)
#else
before_exec();
execl("/bin/sh", "sh", "-c", str, (char *)NULL);
- after_exec();
+ preserving_errno(after_exec());
#endif
#endif
return -1;