summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-04-04 08:08:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-04-04 08:08:46 +0000
commitf67fc8a43f781585da51474c3e2a1356a8f0524e (patch)
treee64f97c6bda04b96b986d0cc205dbc082f28c919 /io.c
parent496371638e73b962e594acecb976c0dbb70d0ad3 (diff)
* io.c (pipe_open): refined the message of NotImplementedError.
[ruby-dev:30685] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/io.c b/io.c
index 69df268226..3284ee6205 100644
--- a/io.c
+++ b/io.c
@@ -3026,12 +3026,29 @@ pipe_open(pstr, pname, mode)
{
int modef = rb_io_mode_flags(mode);
OpenFile *fptr;
-
#if defined(DJGPP) || defined(__human68k__) || defined(__VMS)
FILE *f;
+#else
+ int pid;
+#ifdef _WIN32
+ FILE *fpr, *fpw;
+#else
+ int pr[2], pw[2];
+#endif
+#endif
+ volatile int doexec;
if (!pname) pname = StringValueCStr(pstr);
- if (strcmp("-", pname) == 0) rb_notimplement();
+ doexec = (strcmp("-", pname) != 0);
+
+#if defined(DJGPP) || defined(__human68k__) || defined(__VMS) || defined(_WIN32)
+ if (!doexec) {
+ rb_raise(rb_eNotImpError,
+ "The fork(2) function is unimplemented on this machine");
+ }
+#endif
+
+#if defined(DJGPP) || defined(__human68k__) || defined(__VMS)
f = popen(pname, mode);
if (!f) rb_sys_fail(pname);
@@ -3053,11 +3070,6 @@ pipe_open(pstr, pname, mode)
}
#else
#ifdef _WIN32
- int pid;
- FILE *fpr, *fpw;
-
- if (!pname) pname = StringValueCStr(pstr);
- if (strcmp("-", pname) == 0) rb_notimplement();
retry:
pid = pipe_exec(pname, rb_io_mode_modenum(mode), &fpr, &fpw);
if (pid == -1) { /* exec failed */
@@ -3087,16 +3099,10 @@ retry:
return (VALUE)port;
}
#else
- int pid, pr[2], pw[2];
- volatile int doexec;
-
- if (!pname) pname = StringValueCStr(pstr);
-
if (((modef & FMODE_READABLE) && pipe(pr) == -1) ||
((modef & FMODE_WRITABLE) && pipe(pw) == -1))
rb_sys_fail(pname);
- doexec = (strcmp("-", pname) != 0);
if (!doexec) {
fflush(stdin); /* is it really needed? */
fflush(stdout);