From: Nobuyoshi Nakada Date: 2007-04-04T00:41:49+09:00 Subject: [ruby-dev:30681] IO.popen("-") with no fork なかだです。 [ruby-dev:30679]に関連して、win32などのforkのない環境では IO.popen("-")はfork同様NotImplementedErrorになるべきじゃないで しょうか。 Index: io.c =================================================================== --- io.c (revision 12141) +++ io.c (working copy) @@ -3057,9 +3057,9 @@ pipe_open(int argc, VALUE *argv, const c int status; struct popen_arg arg; - volatile int doexec; #elif defined(_WIN32) int openmode = rb_io_mode_modenum(mode); char *exename = NULL; #endif + volatile int doexec; char *cmd; FILE *fp = 0; @@ -3072,7 +3072,8 @@ pipe_open(int argc, VALUE *argv, const c } -#if defined(HAVE_FORK) && defined(HAVE_SOCKETPAIR) cmd = StringValueCStr(prog); doexec = (strcmp("-", cmd) != 0); + +#if defined(HAVE_FORK) && defined(HAVE_SOCKETPAIR) if (!doexec) { fflush(stdin); /* is it really needed? */ @@ -3134,4 +3135,5 @@ pipe_open(int argc, VALUE *argv, const c } #elif defined(_WIN32) + if (!doexec) rb_notimplement(); if (argc) { char **args = ALLOCA_N(char *, argc+1); @@ -3146,7 +3148,4 @@ pipe_open(int argc, VALUE *argv, const c exename = RSTRING_PTR(prog); } - else { - cmd = StringValueCStr(prog); - } while ((pid = rb_w32_pipe_exec(cmd, exename, openmode, &fd)) == -1) { /* exec failed */ @@ -3164,7 +3163,10 @@ pipe_open(int argc, VALUE *argv, const c } #else - if (argc) + if (!doexec) rb_notimplement(); + if (argc) { prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" ")); - fp = popen(StringValueCStr(prog), mode); + cmd = StringValueCStr(prog); + } + fp = popen(cmd, mode); if (!fp) rb_sys_fail(RSTRING_PTR(prog)); fd = fileno(fp); -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦