[#30679] IO.popen doesn't fail for non-existent command — nobu@...
なかだです。
4 messages
2007/04/03
[#30681] IO.popen("-") with no fork — Nobuyoshi Nakada <nobu@...>
なかだです。
13 messages
2007/04/03
[#30685] Re: IO.popen("-") with no fork
— "U.Nakamura" <usa@...>
2007/04/04
こんにちは、なかむら(う)です。
[#30686] Re: IO.popen("-") with no fork
— Yukihiro Matsumoto <matz@...>
2007/04/04
Hi,
[#30687] Re: IO.popen("-") with no fork
— Nobuyoshi Nakada <nobu@...>
2007/04/04
なかだです。
[#30688] Re: IO.popen("-") with no fork
— Yukihiro Matsumoto <matz@...>
2007/04/04
まつもと ゆきひろです
[#30722] JSON ライブラリの取り込み — "NARUSE, Yui" <naruse@...>
naruseです。
20 messages
2007/04/21
[#30723] Re: JSON ライブラリの取り込み
— "Akinori MUSHA" <knu@...>
2007/04/21
At Sat, 21 Apr 2007 12:27:47 +0900,
[#30724] Re: JSON ライブラリの取り込み
— "NAKAMURA, Hiroshi" <nakahiro@...>
2007/04/21
-----BEGIN PGP SIGNED MESSAGE-----
[#30729] Re: Ruby 1.9: multiple splats on rvalues in parallel assignment — SASADA Koichi <ko1@...>
ささだです.
6 messages
2007/04/26
[#30730] Re: Ruby 1.9: multiple splats on rvalues in parallel assignment
— Yukihiro Matsumoto <matz@...>
2007/04/26
まつもと ゆきひろです
[ruby-dev:30681] IO.popen("-") with no fork
From:
Nobuyoshi Nakada <nobu@...>
Date:
2007-04-03 15:41:49 UTC
List:
ruby-dev #30681
なかだです。
[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はできる。
中田 伸悦