aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-04-04 01:17:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-04-04 01:17:34 +0000
commit1f9d0992aba18316b2e08ce2ce00b0b5eb524e48 (patch)
treed7c5bb12fb376dfe6b1d5ae65f840297d9b51a95 /io.c
parent9c64c3ed5c45084e62f46fc6b5d80948697c3f86 (diff)
downloadruby-1f9d0992aba18316b2e08ce2ce00b0b5eb524e48.tar.gz
* io.c (pipe_open): raise NotImplementedError for command "-" on
platforms where fork(2) is not available. [ruby-dev:30681] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/io.c b/io.c
index b9a84e11e4..60bee39968 100644
--- a/io.c
+++ b/io.c
@@ -3059,11 +3059,11 @@ pipe_open(int argc, VALUE *argv, const char *mode)
#if defined(HAVE_FORK) && defined(HAVE_SOCKETPAIR)
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;
int fd = -1;
@@ -3074,9 +3074,10 @@ pipe_open(int argc, VALUE *argv, const char *mode)
prog = argv[0];
}
-#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? */
rb_io_flush(rb_stdout);
@@ -3136,6 +3137,7 @@ pipe_open(int argc, VALUE *argv, const char *mode)
fd = arg.pair[1];
}
#elif defined(_WIN32)
+ if (!doexec) rb_notimplement();
if (argc) {
char **args = ALLOCA_N(char *, argc+1);
int i;
@@ -3148,9 +3150,6 @@ pipe_open(int argc, VALUE *argv, const char *mode)
rb_w32_join_argv(cmd, args);
exename = RSTRING_PTR(prog);
}
- else {
- cmd = StringValueCStr(prog);
- }
while ((pid = rb_w32_pipe_exec(cmd, exename, openmode, &fd)) == -1) {
/* exec failed */
switch (errno) {
@@ -3166,9 +3165,12 @@ pipe_open(int argc, VALUE *argv, const char *mode)
}
}
#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);
#endif