mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (pipe_open): refined the message of NotImplementedError.
[ruby-dev:30685] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7f8eb55d6c
commit
8259e4aa9a
2 changed files with 24 additions and 11 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Apr 4 17:09:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (pipe_open): refined the message of NotImplementedError.
|
||||||
|
[ruby-dev:30685]
|
||||||
|
|
||||||
Wed Apr 4 12:29:02 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
Wed Apr 4 12:29:02 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* error.c (rb_notimplement): should show the name of this func,
|
* error.c (rb_notimplement): should show the name of this func,
|
||||||
|
|
30
io.c
30
io.c
|
@ -3056,7 +3056,7 @@ pipe_open(int argc, VALUE *argv, const char *mode)
|
||||||
int pid = 0;
|
int pid = 0;
|
||||||
rb_io_t *fptr;
|
rb_io_t *fptr;
|
||||||
VALUE port, prog;
|
VALUE port, prog;
|
||||||
#if defined(HAVE_FORK) && defined(HAVE_SOCKETPAIR)
|
#if defined(HAVE_FORK)
|
||||||
int status;
|
int status;
|
||||||
struct popen_arg arg;
|
struct popen_arg arg;
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
|
@ -3077,7 +3077,14 @@ pipe_open(int argc, VALUE *argv, const char *mode)
|
||||||
cmd = StringValueCStr(prog);
|
cmd = StringValueCStr(prog);
|
||||||
doexec = (strcmp("-", cmd) != 0);
|
doexec = (strcmp("-", cmd) != 0);
|
||||||
|
|
||||||
#if defined(HAVE_FORK) && defined(HAVE_SOCKETPAIR)
|
#if !defined(HAVE_FORK)
|
||||||
|
if (!doexec) {
|
||||||
|
rb_raise(rb_eNotImpError,
|
||||||
|
"The fork(2) function is unimplemented on this machine");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_FORK)
|
||||||
if (!doexec) {
|
if (!doexec) {
|
||||||
fflush(stdin); /* is it really needed? */
|
fflush(stdin); /* is it really needed? */
|
||||||
rb_io_flush(rb_stdout);
|
rb_io_flush(rb_stdout);
|
||||||
|
@ -3085,19 +3092,22 @@ pipe_open(int argc, VALUE *argv, const char *mode)
|
||||||
}
|
}
|
||||||
arg.modef = modef;
|
arg.modef = modef;
|
||||||
arg.pair[0] = arg.pair[1] = -1;
|
arg.pair[0] = arg.pair[1] = -1;
|
||||||
if ((modef & FMODE_READABLE) && (modef & FMODE_WRITABLE)) {
|
switch (modef & (FMODE_READABLE|FMODE_WRITABLE)) {
|
||||||
|
#if defined(HAVE_SOCKETPAIR)
|
||||||
|
case FMODE_READABLE|FMODE_WRITABLE:
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, arg.pair) < 0)
|
if (socketpair(AF_UNIX, SOCK_STREAM, 0, arg.pair) < 0)
|
||||||
rb_sys_fail(cmd);
|
rb_sys_fail(cmd);
|
||||||
}
|
break;
|
||||||
else if (modef & FMODE_READABLE) {
|
#endif
|
||||||
|
case FMODE_READABLE:
|
||||||
if (pipe(arg.pair) < 0)
|
if (pipe(arg.pair) < 0)
|
||||||
rb_sys_fail(cmd);
|
rb_sys_fail(cmd);
|
||||||
}
|
break;
|
||||||
else if (modef & FMODE_WRITABLE) {
|
case FMODE_WRITABLE:
|
||||||
if (pipe(arg.pair) < 0)
|
if (pipe(arg.pair) < 0)
|
||||||
rb_sys_fail(cmd);
|
rb_sys_fail(cmd);
|
||||||
}
|
break;
|
||||||
else {
|
default:
|
||||||
rb_sys_fail(cmd);
|
rb_sys_fail(cmd);
|
||||||
}
|
}
|
||||||
if (doexec) {
|
if (doexec) {
|
||||||
|
@ -3137,7 +3147,6 @@ pipe_open(int argc, VALUE *argv, const char *mode)
|
||||||
fd = arg.pair[1];
|
fd = arg.pair[1];
|
||||||
}
|
}
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
if (!doexec) rb_notimplement();
|
|
||||||
if (argc) {
|
if (argc) {
|
||||||
char **args = ALLOCA_N(char *, argc+1);
|
char **args = ALLOCA_N(char *, argc+1);
|
||||||
int i;
|
int i;
|
||||||
|
@ -3165,7 +3174,6 @@ pipe_open(int argc, VALUE *argv, const char *mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (!doexec) rb_notimplement();
|
|
||||||
if (argc) {
|
if (argc) {
|
||||||
prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
|
prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
|
||||||
cmd = StringValueCStr(prog);
|
cmd = StringValueCStr(prog);
|
||||||
|
|
Loading…
Reference in a new issue