diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-23 13:15:54 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-23 13:15:54 +0000 |
| commit | a65c967980292003dfeb9275ecb1baf41ae13894 (patch) | |
| tree | 4c97f969fd904f2dd8f22d0209812aedbdd7203c /io.c | |
| parent | f4582b74a6e9c0b2874eb8e40ca92a60258e1849 (diff) | |
| download | ruby-a65c967980292003dfeb9275ecb1baf41ae13894.tar.gz ruby-a65c967980292003dfeb9275ecb1baf41ae13894.tar.xz ruby-a65c967980292003dfeb9275ecb1baf41ae13894.zip | |
* process.c (rb_fork): propagete an error message from child to parent.
(rb_f_exec): show details of error in child process on
exception.
(save_redirect_fd): add error message arguments.
(run_exec_dup2): ditto.
(run_exec_close): ditto.
(run_exec_open): ditto.
(run_exec_dup2_child): ditto.
(run_exec_pgroup): ditto.
(run_exec_rlimit): ditto.
(rb_run_exec_options): ditto.
(rb_exec): ditto.
(rb_exec_atfork): ditto.
(rb_spawn_internal): ditto.
(rb_spawn): ditto.
(rb_f_system): follow arguments change.
(proc_daemon): ditto.
(rb_f_spawn): show details of error in child process on exception.
* io.c (popen_exec): add error message arguments.
(pipe_open): show details of error in child process on exception.
* include/ruby/intern.h (rb_run_exec_options): add error message
arguments.
(rb_exec): ditto.
(rb_fork): ditto.
(rb_spawn): ditto.
* ext/pty/pty.c (chfunc): add error message arguments.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
| -rw-r--r-- | io.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -4440,12 +4440,12 @@ rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds) } static int -popen_exec(void *pp) +popen_exec(void *pp, char *errmsg, size_t errmsg_len) { struct popen_arg *p = (struct popen_arg*)pp; rb_thread_atfork_before_exec(); - return rb_exec(p->execp); + return rb_exec(p->execp, errmsg, errmsg_len); } #endif @@ -4460,6 +4460,7 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, #if defined(HAVE_FORK) int status; struct popen_arg arg; + char errmsg[80] = { '\0' }; #elif defined(_WIN32) volatile VALUE argbuf; char **args = NULL; @@ -4530,11 +4531,11 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, } if (eargp) { rb_exec_arg_fixup(arg.execp); - pid = rb_fork(&status, popen_exec, &arg, arg.execp->redirect_fds); + pid = rb_fork(&status, popen_exec, &arg, arg.execp->redirect_fds, errmsg, sizeof(errmsg)); } else { fflush(stdin); /* is it really needed? */ - pid = rb_fork(&status, 0, 0, Qnil); + pid = rb_fork(&status, 0, 0, Qnil, NULL, 0); if (pid == 0) { /* child */ popen_redirect(&arg); rb_io_synchronized(RFILE(orig_stdout)->fptr); @@ -4553,6 +4554,8 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, close(arg.write_pair[1]); } errno = e; + if (errmsg[0]) + rb_sys_fail(errmsg); rb_sys_fail(cmd); } if ((fmode & FMODE_READABLE) && (fmode & FMODE_WRITABLE)) { @@ -4616,7 +4619,7 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, } if (eargp) { rb_exec_arg_fixup(eargp); - rb_run_exec_options(eargp, &sarg); + rb_run_exec_options(eargp, &sarg, NULL, 0); } while ((pid = (args ? rb_w32_aspawn(P_NOWAIT, 0, args) : @@ -4631,13 +4634,13 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, break; default: if (eargp) - rb_run_exec_options(&sarg, NULL); + rb_run_exec_options(&sarg, NULL, NULL, 0); rb_sys_fail(cmd); break; } } if (eargp) - rb_run_exec_options(&sarg, NULL); + rb_run_exec_options(&sarg, NULL, NULL, 0); if ((fmode & FMODE_READABLE) && (fmode & FMODE_WRITABLE)) { close(pair[1]); fd = pair[0]; @@ -4659,11 +4662,11 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode, } if (eargp) { rb_exec_arg_fixup(eargp); - rb_run_exec_options(eargp, &sarg); + rb_run_exec_options(eargp, &sarg, NULL, 0); } fp = popen(cmd, modestr); if (eargp) - rb_run_exec_options(&sarg, NULL); + rb_run_exec_options(&sarg, NULL, NULL, 0); if (!fp) rb_sys_fail(RSTRING_PTR(prog)); fd = fileno(fp); #endif |
