summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
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 6064cd11425..00b557b379b 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:
@@ -989,7 +992,7 @@ proc_exec_v(argv, prog)
#endif /* MSDOS or __human68k__ or __EMX__ */
before_exec();
execv(prog, argv);
- after_exec();
+ preserving_errno(after_exec());
return -1;
}
@@ -1058,7 +1061,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;