summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-28 18:26:01 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-28 18:26:01 +0000
commit2f2143a2bef3d2e3d93fbb044c5f066b57cefc2b (patch)
treeccd6bc1b730eeb5e3d20f5b65391e7836bbd943b /io.c
parentcd6cffa7b6b4828016f5ff0cffdde732a0548a92 (diff)
* io.c (pipe_finalize, pipe_popen): two-way pipe support for win32.
* win32/win32.c (ChildRecord, FindFreeChildSlot): ditto. * win32/win32.c, win32/win32.h (pipe_exec): new function for two-way pipe support for win32. * win32/win32.c, win32/win32.h (FindPipedChildSlot, rb_w32_popen, rb_w32_pclose): removed functions for two-way pipe support for win32. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/io.c b/io.c
index 41a5ac9..591ac8d 100644
--- a/io.c
+++ b/io.c
@@ -1761,7 +1761,7 @@ static void
pipe_finalize(fptr)
OpenFile *fptr;
{
-#if !defined (__CYGWIN__)
+#if !defined (__CYGWIN__) && !defined(NT)
extern VALUE rb_last_status;
int status;
if (fptr->f) {
@@ -1803,7 +1803,7 @@ pipe_open(pname, mode)
int modef = rb_io_mode_flags(mode);
OpenFile *fptr;
-#if defined(NT) || defined(DJGPP) || defined(__human68k__) || defined(__VMS)
+#if defined(DJGPP) || defined(__human68k__) || defined(__VMS)
FILE *f = popen(pname, mode);
if (!f) rb_sys_fail(pname);
@@ -1821,7 +1821,40 @@ pipe_open(pname, mode)
else fptr->f = f;
rb_io_synchronized(fptr);
}
- return port;
+ return (VALUE)port;
+ }
+#else
+#if defined(NT)
+ int pid;
+ FILE *fpr, *fpw;
+
+retry:
+ pid = pipe_exec(pname, rb_io_mode_modenum(mode), &fpr, &fpw);
+ if (pid == -1) { /* exec failed */
+ if (errno == EAGAIN) {
+ rb_thread_sleep(1);
+ goto retry;
+ }
+ rb_sys_fail(pname);
+ }
+ else {
+ VALUE port = rb_obj_alloc(rb_cIO);
+
+ MakeOpenFile(port, fptr);
+ fptr->mode = modef;
+ fptr->mode |= FMODE_SYNC;
+ fptr->pid = pid;
+
+ if (modef & FMODE_READABLE) {
+ fptr->f = fpr;
+ }
+ if (modef & FMODE_WRITABLE) {
+ if (fptr->f) fptr->f2 = fpw;
+ else fptr->f = fpw;
+ }
+ fptr->finalize = pipe_finalize;
+ pipe_add_fptr(fptr);
+ return (VALUE)port;
}
#else
int pid, pr[2], pw[2];
@@ -1908,6 +1941,7 @@ pipe_open(pname, mode)
}
}
#endif
+#endif
}
static VALUE