mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
process.c, ext/pty/pty.c: status on errors
* process.c (rb_fork_err): determine status on errors. * ext/pty/pty.c (establishShell): reraise exception if something raised during sleep. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bc81a19e99
commit
182dc9d40d
3 changed files with 11 additions and 2 deletions
|
@ -1,4 +1,9 @@
|
|||
Fri Jun 8 11:25:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Fri Jun 8 11:26:37 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* process.c (rb_fork_err): determine status on errors.
|
||||
|
||||
* ext/pty/pty.c (establishShell): reraise exception if something
|
||||
raised during sleep.
|
||||
|
||||
* ext/pty/pty.c (establishShell): now needs status to protect from
|
||||
exceptions in rb_fork_err().
|
||||
|
|
|
@ -196,6 +196,7 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
|
|||
close(master);
|
||||
close(slave);
|
||||
errno = e;
|
||||
if (status) rb_jump_tag(status);
|
||||
rb_sys_fail(errbuf[0] ? errbuf : "fork failed");
|
||||
}
|
||||
|
||||
|
|
|
@ -2736,7 +2736,9 @@ chfunc_protect(VALUE arg)
|
|||
* process.
|
||||
*
|
||||
* If +status+ is given, protects from any exceptions and sets the
|
||||
* jump status to it.
|
||||
* jump status to it, and returns -1. If failed to fork new process
|
||||
* but no exceptions occurred, sets 0 to it. Otherwise, if forked
|
||||
* successfully, the value of +status+ is undetermined.
|
||||
*
|
||||
* In the child process, just returns 0 if +chfunc+ is +NULL+.
|
||||
* Otherwise +chfunc+ will be called with +charg+, and then the child
|
||||
|
@ -2773,6 +2775,7 @@ rb_fork_err(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALU
|
|||
|
||||
#ifdef FD_CLOEXEC
|
||||
if (chfunc) {
|
||||
if (status) *status = 0;
|
||||
if (pipe_nocrash(ep, fds)) return -1;
|
||||
if (fcntl(ep[1], F_SETFD, FD_CLOEXEC)) {
|
||||
preserving_errno((close(ep[0]), close(ep[1])));
|
||||
|
|
Loading…
Reference in a new issue