Mercurial > hg > octave-nkf
comparison src/oct-procbuf.cc @ 4472:f52db9e1296a
[project @ 2003-07-29 18:03:03 by jwe]
author | jwe |
---|---|
date | Tue, 29 Jul 2003 18:03:03 +0000 |
parents | ccfdb55c8156 |
children | 4c8a2e4e0717 |
comparison
equal
deleted
inserted
replaced
4471:6a1e6e87f143 | 4472:f52db9e1296a |
---|---|
54 static octave_procbuf *octave_procbuf_list = 0; | 54 static octave_procbuf *octave_procbuf_list = 0; |
55 | 55 |
56 octave_procbuf * | 56 octave_procbuf * |
57 octave_procbuf::open (const char *command, int mode) | 57 octave_procbuf::open (const char *command, int mode) |
58 { | 58 { |
59 #if defined (HAVE_SYS_WAIT_H) | 59 #if defined (__CYGWIN32__) |
60 | |
61 if (is_open ()) | |
62 return 0; | |
63 | |
64 f = popen (command, (mode & std::ios::in) ? "r" : "w"); | |
65 | |
66 if (! f) | |
67 return 0; | |
68 | |
69 // Oops... popen doesn't return the associated pid, so fake it for now | |
70 | |
71 proc_pid = 1; | |
72 | |
73 open_p = true; | |
74 | |
75 if (mode & std::ios::out) | |
76 ::setvbuf (f, 0, _IOLBF, 0); | |
77 | |
78 return this; | |
79 | |
80 #elif defined (HAVE_SYS_WAIT_H) | |
60 | 81 |
61 int pipe_fds[2]; | 82 int pipe_fds[2]; |
62 | 83 |
63 volatile int child_std_end = (mode & std::ios::in) ? 1 : 0; | 84 volatile int child_std_end = (mode & std::ios::in) ? 1 : 0; |
64 | 85 |
142 } | 163 } |
143 | 164 |
144 octave_procbuf * | 165 octave_procbuf * |
145 octave_procbuf::close (void) | 166 octave_procbuf::close (void) |
146 { | 167 { |
147 #if defined (HAVE_SYS_WAIT_H) | 168 #if defined (__CYGWIN32__) |
169 | |
170 if (f) | |
171 { | |
172 wstatus = ::pclose (f); | |
173 f = 0; | |
174 } | |
175 | |
176 open_p = false; | |
177 | |
178 return this; | |
179 | |
180 #elif defined (HAVE_SYS_WAIT_H) | |
148 | 181 |
149 if (f) | 182 if (f) |
150 { | 183 { |
151 pid_t wait_pid; | 184 pid_t wait_pid; |
152 | 185 |