author | Stefan Vogel <sv@exept.de> |
Mon, 04 Mar 2002 15:21:43 +0100 | |
changeset 6439 | 0f841258ec4a |
parent 6267 | 10016cc16511 |
child 6487 | 78c18e4cb6ff |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
5388
bef4d52749a4
terminate command on close (also under unix)
Claus Gittinger <cg@exept.de>
parents:
5243
diff
changeset
|
13 |
"{ Package: 'stx:libbasic' }" |
bef4d52749a4
terminate command on close (also under unix)
Claus Gittinger <cg@exept.de>
parents:
5243
diff
changeset
|
14 |
|
269 | 15 |
NonPositionableExternalStream subclass:#PipeStream |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
16 |
instanceVariableNames:'commandString pid exitStatus exitSema exitAction' |
1295 | 17 |
classVariableNames:'BrokenPipeSignal' |
18 |
poolDictionaries:'' |
|
19 |
category:'Streams-External' |
|
88 | 20 |
! |
2 | 21 |
|
217 | 22 |
!PipeStream primitiveDefinitions! |
88 | 23 |
%{ |
437 | 24 |
|
4616 | 25 |
#if defined(WIN32) |
793 | 26 |
# undef UNIX_LIKE |
27 |
# define MSDOS_LIKE |
|
28 |
#endif |
|
29 |
||
88 | 30 |
#include <stdio.h> |
437 | 31 |
#define _STDIO_H_INCLUDED_ |
32 |
||
88 | 33 |
#include <errno.h> |
437 | 34 |
#define _ERRNO_H_INCLUDED_ |
35 |
||
88 | 36 |
#ifndef transputer |
37 |
# include <sys/types.h> |
|
38 |
# include <sys/stat.h> |
|
39 |
#endif |
|
230 | 40 |
|
41 |
/* |
|
42 |
* on some systems errno is a macro ... check for it here |
|
43 |
*/ |
|
44 |
#ifndef errno |
|
45 |
extern errno; |
|
46 |
#endif |
|
47 |
||
1663 | 48 |
#ifdef LINUX |
49 |
# define BUGGY_STDIO_LIB |
|
50 |
#endif |
|
51 |
||
88 | 52 |
%} |
180 | 53 |
! ! |
88 | 54 |
|
325 | 55 |
!PipeStream primitiveFunctions! |
56 |
%{ |
|
57 |
||
58 |
/* |
|
2925 | 59 |
* no longer needed - popen is useless ... |
60 |
*/ |
|
61 |
#undef NEED_POPEN_WITH_VFORK |
|
62 |
||
63 |
/* |
|
325 | 64 |
* some systems (i.e. ultrix) use fork; |
65 |
* were better off with a popen based on vfork ... |
|
66 |
*/ |
|
67 |
#ifdef NEED_POPEN_WITH_VFORK |
|
68 |
||
69 |
static int popen_pid = 0; |
|
70 |
||
71 |
FILE * |
|
72 |
popen(command, type) |
|
73 |
/* const */ char *command; |
|
74 |
/* const */ char *type; |
|
75 |
{ |
|
76 |
int pipes[2]; |
|
77 |
int itype = (strcmp(type, "w") == 0 ? 1 : 0); |
|
78 |
||
79 |
if (pipe(pipes) == -1) |
|
326 | 80 |
return NULL; |
325 | 81 |
|
82 |
switch (popen_pid = vfork()) { |
|
83 |
case -1: |
|
326 | 84 |
(void)close(pipes[0]); |
85 |
(void)close(pipes[1]); |
|
86 |
return NULL; |
|
325 | 87 |
|
88 |
case 0: |
|
326 | 89 |
if (itype) { |
90 |
dup2(pipes[0], fileno(stdin)); |
|
91 |
close(pipes[1]); |
|
92 |
} else { |
|
93 |
dup2(pipes[1], fileno(stdout)); |
|
94 |
close(pipes[0]); |
|
95 |
} |
|
96 |
execl("/bin/sh", "/bin/sh", "-c", command, 0); |
|
97 |
fprintf(stderr, "XRN Error: failed the execlp\n"); |
|
98 |
_exit(-1); |
|
99 |
/* NOTREACHED */ |
|
325 | 100 |
|
101 |
default: |
|
326 | 102 |
if (itype) { |
103 |
close(pipes[0]); |
|
104 |
return fdopen(pipes[1], "w"); |
|
105 |
} else { |
|
106 |
close(pipes[1]); |
|
107 |
return fdopen(pipes[0], "r"); |
|
108 |
} |
|
325 | 109 |
} |
110 |
} |
|
111 |
||
112 |
int |
|
113 |
pclose(str) |
|
114 |
FILE *str; |
|
115 |
{ |
|
116 |
int pd = 0; |
|
117 |
int status; |
|
118 |
int err; |
|
119 |
||
120 |
err = fclose(str); |
|
121 |
||
122 |
do { |
|
326 | 123 |
if ((pd = wait(&status)) == -1) |
124 |
{ |
|
125 |
err = EOF; |
|
126 |
break; |
|
127 |
} |
|
325 | 128 |
} while (pd != popen_pid); |
129 |
||
130 |
if (err == EOF) |
|
326 | 131 |
return -1; |
325 | 132 |
|
133 |
if (status) |
|
326 | 134 |
status >>= 8; /* exit status in high byte */ |
325 | 135 |
|
136 |
return status; |
|
137 |
} |
|
138 |
||
2925 | 139 |
#endif /* NEED_POPEN_WITH_VFORK */ |
325 | 140 |
|
141 |
%} |
|
142 |
! ! |
|
143 |
||
2266 | 144 |
!PipeStream class methodsFor:'documentation'! |
613 | 145 |
|
146 |
copyright |
|
147 |
" |
|
148 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
149 |
All Rights Reserved |
|
150 |
||
151 |
This software is furnished under a license and may be used |
|
152 |
only in accordance with the terms of that license and with the |
|
153 |
inclusion of the above copyright notice. This software may not |
|
154 |
be provided or otherwise made available to, or used by, any |
|
155 |
other person. No title to or ownership of the software is |
|
156 |
hereby transferred. |
|
157 |
" |
|
158 |
! |
|
159 |
||
160 |
documentation |
|
161 |
" |
|
162 |
Pipestreams allow reading or writing from/to a unix command. |
|
163 |
For example, to get a stream reading the output of an 'ls -l' |
|
164 |
command, a PipeStream can be created with: |
|
165 |
||
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
166 |
PipeStream readingFrom:'ls -l' |
613 | 167 |
|
168 |
the characters of the commands output can be read using the |
|
169 |
standard stream messages as next, nextLine etc. |
|
170 |
||
171 |
If a writing pipeStream is written to, after the command has finished, |
|
2966 | 172 |
UNIX will generate an error-signal (SIGPIPE), which will raise the BrokenPipeSignal. |
613 | 173 |
Thus, to handle this condition correctly, the following code is suggested: |
174 |
||
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
175 |
|p| |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
176 |
p := PipeStream writingTo:'echo hello'. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
177 |
PipeStream brokenPipeSignal handle:[:ex | |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
178 |
'broken pipe' printNewline. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
179 |
p shutDown. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
180 |
ex return |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
181 |
] do:[ |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
182 |
p nextPutLine:'oops'. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
183 |
'after write' printNewline. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
184 |
p close. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
185 |
'after close' printNewline |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
186 |
] |
613 | 187 |
|
1663 | 188 |
Notice, that iff the Stream is buffered, the Signal may occur some time after |
613 | 189 |
the write - or even at close time; to avoid a recursive signal in the exception |
2966 | 190 |
handler, a #shutDown is useful there; if you use close in the handler, this would |
191 |
try to send any buffered output to the pipe, leading to another brokenPipe exception. |
|
1295 | 192 |
|
1662
ce26ca3d837c
linux stdio does not work with buffered pipes
Claus Gittinger <cg@exept.de>
parents:
1648
diff
changeset
|
193 |
Buffered pipes do not work with Linux - the stdio library seems to be |
ce26ca3d837c
linux stdio does not work with buffered pipes
Claus Gittinger <cg@exept.de>
parents:
1648
diff
changeset
|
194 |
buggy (trying to restart the read ...) |
ce26ca3d837c
linux stdio does not work with buffered pipes
Claus Gittinger <cg@exept.de>
parents:
1648
diff
changeset
|
195 |
|
2966 | 196 |
Currently, no filtering pipeStreams (i.e. both reading AND writing) are provided. |
197 |
However, if you look at how things are setup, this can be implemented using the |
|
198 |
low level primitives #mapePipe and #executeCommand from the OS class protocol. |
|
199 |
||
1295 | 200 |
[author:] |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
201 |
Claus Gittinger |
2966 | 202 |
|
203 |
[see also:] |
|
204 |
ExternalStream FileStream Socket |
|
205 |
OperatingSystem |
|
613 | 206 |
" |
207 |
! ! |
|
208 |
||
2266 | 209 |
!PipeStream class methodsFor:'initialization'! |
2 | 210 |
|
211 |
initialize |
|
212 |
"setup the signal" |
|
213 |
||
57 | 214 |
BrokenPipeSignal isNil ifTrue:[ |
582
21f08116b28d
BrokenPipeSignal now a child of WriteErrorSignal
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
215 |
BrokenPipeSignal := WriteErrorSignal newSignalMayProceed:true. |
159 | 216 |
BrokenPipeSignal nameClass:self message:#brokenPipeSignal. |
217 |
BrokenPipeSignal notifierString:'write on a pipe with no one to read'. |
|
57 | 218 |
] |
2 | 219 |
! ! |
220 |
||
2266 | 221 |
!PipeStream class methodsFor:'instance creation'! |
2 | 222 |
|
613 | 223 |
readingFrom:commandString |
224 |
"create and return a new pipeStream which can read from the unix command |
|
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
225 |
given by command. |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
226 |
The commands error output is send to my own error output." |
2 | 227 |
|
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
228 |
^ self |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
229 |
readingFrom:commandString |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
230 |
errorDisposition:#stderr |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
231 |
inDirectory:nil |
613 | 232 |
|
2966 | 233 |
"unix: |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
234 |
PipeStream readingFrom:'ls -l'. |
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
235 |
" |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
236 |
|
2966 | 237 |
" |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
238 |
p := PipeStream readingFrom:'ls -l'. |
2966 | 239 |
Transcript showCR:p nextLine. |
240 |
p close |
|
241 |
" |
|
242 |
||
243 |
" |
|
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
244 |
|s| |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
245 |
s := PipeStream readingFrom:'sh -c sleep\ 600'. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
246 |
(Delay forSeconds:2) wait. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
247 |
s shutDown |
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
248 |
" |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
249 |
|
2966 | 250 |
"vms: |
251 |
PipeStream readingFrom:'dir'. |
|
252 |
" |
|
253 |
||
254 |
" |
|
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
255 |
|p| |
2966 | 256 |
p := PipeStream readingFrom:'dir'. |
257 |
Transcript showCR:p nextLine. |
|
258 |
p close |
|
259 |
" |
|
260 |
||
261 |
"msdos: |
|
262 |
PipeStream readingFrom:'dir'. |
|
263 |
" |
|
264 |
" |
|
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
265 |
|p| |
2966 | 266 |
p := PipeStream readingFrom:'dir'. |
267 |
Transcript showCR:p nextLine. |
|
268 |
p close |
|
269 |
" |
|
270 |
||
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
271 |
"Modified: 24.4.1996 / 09:09:25 / stefan" |
613 | 272 |
! |
1 | 273 |
|
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
274 |
readingFrom:commandString errorDisposition:errorDisposition inDirectory:aDirectory |
2985
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
275 |
"similar to #readingFrom, but changes the directory while |
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
276 |
executing the command. Use this if a command is to be |
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
277 |
executed in another directory, to avoid any OS dependencies |
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
278 |
in your code. |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
279 |
errorDisposition may be one of #discard, #inline or #stderr (default). |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
280 |
#discard causes stderr to be discarded (/dev/null), |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
281 |
#inline causes it to be merged into the PipeStream and |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
282 |
#stderr causes it to be written to smalltalks own stderr. |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
283 |
Nil is treated like #stderr" |
2985
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
284 |
|
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
285 |
^ self basicNew |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
286 |
openPipeFor:commandString |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
287 |
withMode:'r' |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
288 |
errorDisposition:errorDisposition |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
289 |
inDirectory:aDirectory |
2985
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
290 |
! |
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
291 |
|
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
292 |
readingFrom:commandString inDirectory:aDirectory |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
293 |
"similar to #readingFrom, but changes the directory while |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
294 |
executing the command. Use this if a command is to be |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
295 |
executed in another directory, to avoid any OS dependencies |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
296 |
in your code. |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
297 |
The commands error output is send to my own error output." |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
298 |
|
3563 | 299 |
^ self |
300 |
readingFrom:commandString |
|
301 |
errorDisposition:#stderr |
|
302 |
inDirectory:aDirectory |
|
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
303 |
|
2985
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
304 |
"Modified: 24.9.1997 / 09:33:48 / stefan" |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
305 |
! |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
306 |
|
2 | 307 |
writingTo:commandString |
1 | 308 |
"create and return a new pipeStream which can write to the unix command |
309 |
given by command." |
|
310 |
||
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
311 |
^ self |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
312 |
writingTo:commandString errorDisposition:#stderr inDirectory:nil |
1 | 313 |
|
2966 | 314 |
"unix: |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
315 |
PipeStream writingTo:'sort' |
2966 | 316 |
" |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
317 |
! |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
318 |
|
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
319 |
writingTo:commandString errorDisposition:errorDisposition inDirectory:aDirectory |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
320 |
"similar to #writingTo, but changes the directory while |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
321 |
executing the command. Use this if a command is to be |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
322 |
executed in another directory, to avoid any OS dependencies |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
323 |
in your code. |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
324 |
errorDisposition may be one of #discard, #inline or #stderr (default). |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
325 |
#discard causes stderr to be discarded (/dev/null), |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
326 |
#inline causes it to be written to smalltalks own stdout and |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
327 |
#stderr causes it to be written to smalltalks own stderr. |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
328 |
Nil is treated like #stderr" |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
329 |
|
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
330 |
^ self basicNew |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
331 |
openPipeFor:commandString |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
332 |
withMode:'w' |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
333 |
errorDisposition:errorDisposition |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
334 |
inDirectory:aDirectory |
4526
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
335 |
! |
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
336 |
|
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
337 |
writingTo:commandString inDirectory:aDirectory |
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
338 |
"create and return a new pipeStream which can write to the unix command |
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
339 |
given by command. The command is executed in the given directory." |
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
340 |
|
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
341 |
^ self |
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
342 |
writingTo:commandString errorDisposition:#stderr inDirectory:aDirectory |
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
343 |
|
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
344 |
"unix: |
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
345 |
PipeStream writingTo:'sort' |
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4202
diff
changeset
|
346 |
" |
613 | 347 |
! ! |
348 |
||
2266 | 349 |
!PipeStream class methodsFor:'Signal constants'! |
1 | 350 |
|
613 | 351 |
brokenPipeSignal |
2985
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
352 |
"return the signal used to handle SIGPIPE unix-signals. |
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
353 |
Since SIGPIPE is asynchronous, we can't decide which smalltalk process |
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
354 |
should handle BrokenPipeSignal. So the system doesn't raise |
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
355 |
BrokenPipeSignal for SIGPIPE any longer." |
1 | 356 |
|
613 | 357 |
^ BrokenPipeSignal |
2985
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
358 |
|
eff9e86dd2f9
New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents:
2976
diff
changeset
|
359 |
"Modified: 24.9.1997 / 09:43:23 / stefan" |
1 | 360 |
! ! |
361 |
||
99 | 362 |
!PipeStream methodsFor:'accessing'! |
363 |
||
364 |
commandString |
|
365 |
"return the command string" |
|
366 |
||
367 |
^ commandString |
|
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
368 |
! |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
369 |
|
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
370 |
exitStatus |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
371 |
"return exitStatus" |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
372 |
|
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
373 |
^ exitStatus |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
374 |
|
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
375 |
"Created: 28.12.1995 / 14:54:41 / stefan" |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
376 |
! |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
377 |
|
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
378 |
pid |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
379 |
"return pid" |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
380 |
|
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
381 |
^ pid |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
382 |
|
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
383 |
"Created: 28.12.1995 / 14:54:30 / stefan" |
99 | 384 |
! ! |
385 |
||
5243 | 386 |
!PipeStream methodsFor:'finalization'! |
387 |
||
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6267
diff
changeset
|
388 |
finalize |
5243 | 389 |
"redefined to avoid blocking in close." |
390 |
||
391 |
self shutDown |
|
392 |
! ! |
|
393 |
||
1 | 394 |
!PipeStream methodsFor:'instance release'! |
395 |
||
396 |
closeFile |
|
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
397 |
"low level close |
230 | 398 |
This waits for the command to finish. |
399 |
Use shutDown for a fast (nonBlocking) close." |
|
1 | 400 |
|
3834
93ec07316a98
oops - must nil pid when terminating the process
Claus Gittinger <cg@exept.de>
parents:
3833
diff
changeset
|
401 |
|tpid| |
93ec07316a98
oops - must nil pid when terminating the process
Claus Gittinger <cg@exept.de>
parents:
3833
diff
changeset
|
402 |
|
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
403 |
filePointer notNil ifTrue:[ |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
404 |
super closeFile. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
405 |
OperatingSystem isMSDOSlike ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
406 |
self terminatePipeCommand. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
407 |
]. |
3834
93ec07316a98
oops - must nil pid when terminating the process
Claus Gittinger <cg@exept.de>
parents:
3833
diff
changeset
|
408 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
409 |
filePointer := nil. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
410 |
pid notNil ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
411 |
"/ wait for the pipe-command to terminate. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
412 |
self waitForPipeCommandWithTimeout:nil. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
413 |
]. |
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
414 |
]. |
3833
3ae90f8da01a
terminate process BEFORE closing the pipe under win32
Claus Gittinger <cg@exept.de>
parents:
3791
diff
changeset
|
415 |
|
3834
93ec07316a98
oops - must nil pid when terminating the process
Claus Gittinger <cg@exept.de>
parents:
3833
diff
changeset
|
416 |
"Modified: / 12.9.1998 / 16:51:04 / cg" |
369 | 417 |
! |
418 |
||
419 |
closeFileDescriptor |
|
420 |
"alternative very low level close |
|
421 |
This closes the underlying OS-fileDescriptor |
|
422 |
- and will NOT write any buffered data to the stream. |
|
423 |
You have been warned." |
|
424 |
||
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
425 |
|action| |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
426 |
|
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
427 |
%{ |
3296 | 428 |
#if !defined(transputer) |
369 | 429 |
OBJ fp; |
430 |
FILE *f; |
|
4616 | 431 |
extern close(); |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
432 |
int retVal; |
369 | 433 |
|
1133 | 434 |
if ((fp = __INST(filePointer)) != nil) { |
435 |
__INST(filePointer) = nil; |
|
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
436 |
f = __FILEVal(fp); |
5203 | 437 |
if (@global(ExternalStream:FileOpenTrace) == true) { |
438 |
fprintf(stderr, "close [PipeStream] %x fd=%d\n", f, fileno(f)); |
|
439 |
} |
|
3744 | 440 |
#ifdef WIN32 |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
441 |
do { |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
442 |
__threadErrno = 0; |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
443 |
retVal = __STX_C_CALL1( "close", (void*)close, (void*)fileno(f) ); |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
444 |
} while ((retVal < 0) && (__threadErrno == EINTR)); |
3744 | 445 |
#else |
369 | 446 |
__BEGIN_INTERRUPTABLE__ |
447 |
close(fileno(f)); |
|
448 |
__END_INTERRUPTABLE__ |
|
3744 | 449 |
#endif |
369 | 450 |
} |
3296 | 451 |
#endif /* not transputer */ |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
452 |
%}. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
453 |
exitAction notNil ifTrue:[ |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
454 |
action := exitAction. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
455 |
exitAction := nil. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
456 |
action value. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
457 |
] |
613 | 458 |
! |
459 |
||
460 |
shutDown |
|
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
461 |
"close the Stream, ignoring any broken-pipe errors. |
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
462 |
Terminate the command" |
613 | 463 |
|
464 |
BrokenPipeSignal catch:[ |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
465 |
Lobby unregister:self. |
3833
3ae90f8da01a
terminate process BEFORE closing the pipe under win32
Claus Gittinger <cg@exept.de>
parents:
3791
diff
changeset
|
466 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
467 |
"/ terminate first under windows. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
468 |
OperatingSystem isMSDOSlike ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
469 |
self terminatePipeCommand. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
470 |
]. |
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
471 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
472 |
self closeFileDescriptor. |
3834
93ec07316a98
oops - must nil pid when terminating the process
Claus Gittinger <cg@exept.de>
parents:
3833
diff
changeset
|
473 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
474 |
"/ terminate last under unix. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
475 |
OperatingSystem isMSDOSlike ifFalse:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
476 |
self terminatePipeCommand. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
477 |
]. |
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
478 |
|
613 | 479 |
] |
1648
faa891d2c1b0
Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents:
1295
diff
changeset
|
480 |
|
3833
3ae90f8da01a
terminate process BEFORE closing the pipe under win32
Claus Gittinger <cg@exept.de>
parents:
3791
diff
changeset
|
481 |
"Modified: / 23.5.1996 / 09:15:41 / stefan" |
3834
93ec07316a98
oops - must nil pid when terminating the process
Claus Gittinger <cg@exept.de>
parents:
3833
diff
changeset
|
482 |
"Modified: / 12.9.1998 / 16:50:18 / cg" |
5456 | 483 |
! |
484 |
||
485 |
terminatePipeCommand |
|
486 |
|tpid| |
|
487 |
||
488 |
(tpid := pid) notNil ifTrue:[ |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
489 |
OperatingSystem terminateProcess:tpid. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
490 |
OperatingSystem terminateProcessGroup:tpid. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
491 |
pid := nil. |
5456 | 492 |
]. |
493 |
||
494 |
! |
|
495 |
||
496 |
waitForPipeCommandWithTimeout:seconds |
|
497 |
"wait for the pipe command to terminate itself. |
|
498 |
Return true, if a timeout occurred." |
|
499 |
||
500 |
pid notNil ifTrue:[ |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
501 |
[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
502 |
pid notNil ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
503 |
exitSema waitWithTimeout:seconds. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
504 |
] |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
505 |
] valueUninterruptably |
5456 | 506 |
]. |
507 |
^ pid notNil |
|
1 | 508 |
! ! |
509 |
||
510 |
!PipeStream methodsFor:'private'! |
|
511 |
||
2969
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
512 |
exitAction:aBlock |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
513 |
"define a block to be evaluated when the pipe is closed. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
514 |
This is only used with VMS, to remove any temporary COM file. |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
515 |
(see readingFrom:inDirectory:)" |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
516 |
|
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
517 |
exitAction := aBlock |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
518 |
! |
1fcf6dfb6004
VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
519 |
|
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
520 |
openPipeFor:aCommandString withMode:rwMode errorDisposition:err inDirectory:aDirectory |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
521 |
"open a pipe to the OS command in commandString; |
5481 | 522 |
rwMode may be 'r' or 'w'. |
523 |
errorDisposition controls where the stdErr output should go, |
|
524 |
and may be one of #discard, #inline or #stderr (default). |
|
525 |
#discard causes stderr to be discarded (/dev/null), |
|
526 |
#inline causes it to be written to smalltalks own stdout and |
|
527 |
#stderr causes it to be written to smalltalks own stderr. |
|
528 |
Nil is treated like #stderr" |
|
3296 | 529 |
|
530 |
|blocked pipeFdArray execFdArray execFd myFd shellAndArgs |
|
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
531 |
shellPath shellArgs closeFdArray mbx mbxName |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
532 |
realCmd execDirectory tmpComFile nullOutput| |
3296 | 533 |
|
534 |
filePointer notNil ifTrue:[ |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
535 |
"the pipe was already open ... |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
536 |
this should (can) not happen." |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
537 |
^ self errorAlreadyOpen |
3296 | 538 |
]. |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
539 |
|
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
540 |
rwMode = 'r' ifTrue:[ |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
541 |
mode := #readonly. didWrite := false. |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
542 |
] ifFalse:[ |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
543 |
mode := #writeonly. didWrite := true. |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
544 |
]. |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
545 |
|
3296 | 546 |
lastErrorNumber := nil. |
547 |
exitStatus := nil. |
|
548 |
exitSema := Semaphore new name:'pipe exitSema'. |
|
549 |
||
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
550 |
realCmd := aCommandString. |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
551 |
execDirectory := aDirectory. |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
552 |
|
3791 | 553 |
OperatingSystem isVMSlike ifTrue:[ |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
554 |
"/ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
555 |
"/ the generated COM-file includes a 'set default' |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
556 |
"/ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
557 |
tmpComFile := OperatingSystem createCOMFileForVMSCommand:aCommandString in:aDirectory. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
558 |
realCmd := '@' , tmpComFile osName. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
559 |
execDirectory := nil. |
4616 | 560 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
561 |
mbx := OperatingSystem createMailBox. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
562 |
mbx isNil ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
563 |
lastErrorNumber := OperatingSystem currentErrorNumber. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
564 |
tmpComFile delete. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
565 |
^ self openError |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
566 |
]. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
567 |
mbxName := OperatingSystem mailBoxNameOf:mbx. |
3296 | 568 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
569 |
"/ 'mailBox is ' print. mbx print. ' name is ' print. mbxName printCR. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
570 |
shellPath := ''. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
571 |
shellArgs := realCmd. |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
572 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
573 |
rwMode = 'r' ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
574 |
execFdArray := Array with:0 with:mbx with:2. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
575 |
(err == #inline or:[err == #stdout]) ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
576 |
execFdArray at:3 put:mbx |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
577 |
] |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
578 |
] ifFalse:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
579 |
execFdArray := Array with:mbx with:1 with:2. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
580 |
(err == #inline or:[err == #stdout]) ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
581 |
execFdArray at:3 put:1 |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
582 |
] |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
583 |
]. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
584 |
closeFdArray := nil. |
3296 | 585 |
] ifFalse:[ |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
586 |
OperatingSystem isUNIXlike ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
587 |
aDirectory notNil ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
588 |
"/ unix - prepend a 'cd' to the command |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
589 |
realCmd := 'cd "' , aDirectory asFilename name, '"; ' , aCommandString. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
590 |
] ifFalse:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
591 |
realCmd := aCommandString |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
592 |
]. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
593 |
execDirectory := nil. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
594 |
]. |
3296 | 595 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
596 |
pipeFdArray := OperatingSystem makePipe. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
597 |
pipeFdArray isNil ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
598 |
lastErrorNumber := OperatingSystem currentErrorNumber. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
599 |
^ self openError |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
600 |
]. |
3296 | 601 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
602 |
shellAndArgs := OperatingSystem commandAndArgsForOSCommand:realCmd. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
603 |
shellPath := shellAndArgs at:1. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
604 |
shellArgs := shellAndArgs at:2. |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
605 |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
606 |
rwMode = 'r' ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
607 |
myFd := pipeFdArray at:1. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
608 |
execFd := pipeFdArray at:2. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
609 |
execFdArray := Array with:0 with:execFd with:2. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
610 |
(err == #inline or:[err == #stdout]) ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
611 |
execFdArray at:3 put:execFd |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
612 |
] |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
613 |
] ifFalse:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
614 |
myFd := pipeFdArray at:2. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
615 |
execFd := pipeFdArray at:1. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
616 |
execFdArray := Array with:execFd with:1 with:2. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
617 |
(err == #inline or:[err == #stdout]) ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
618 |
execFdArray at:3 put:1 |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
619 |
] |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
620 |
]. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
621 |
closeFdArray := Array with:myFd. |
3296 | 622 |
]. |
623 |
||
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
624 |
err == #discard ifTrue:[ |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
625 |
nullOutput := Filename nullDevice writeStream. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
626 |
execFdArray at:3 put:nullOutput fileDescriptor |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
627 |
]. |
3296 | 628 |
|
629 |
"/ must block here, to avoid races due to early finishing |
|
630 |
"/ subprocesses ... |
|
631 |
||
632 |
blocked := OperatingSystem blockInterrupts. |
|
633 |
||
3563 | 634 |
pid := Processor |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
635 |
monitor:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
636 |
OperatingSystem |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
637 |
exec:shellPath |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
638 |
withArguments:shellArgs |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
639 |
fileDescriptors:execFdArray |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
640 |
closeDescriptors:closeFdArray |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
641 |
fork:true |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
642 |
newPgrp:true |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
643 |
inDirectory:execDirectory. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
644 |
] |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
645 |
action:[:status | |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
646 |
status stillAlive ifFalse:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
647 |
exitStatus := status. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
648 |
OperatingSystem closePid:pid. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
649 |
pid := nil. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
650 |
exitSema signal. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
651 |
]. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
652 |
]. |
3296 | 653 |
|
3791 | 654 |
OperatingSystem isVMSlike ifFalse:[ |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
655 |
OperatingSystem closeFd:execFd. |
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
656 |
]. |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
657 |
|
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
658 |
nullOutput notNil ifTrue:[ |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
659 |
nullOutput close |
3296 | 660 |
]. |
661 |
||
662 |
pid notNil ifTrue:[ |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
663 |
OperatingSystem isVMSlike ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
664 |
"/ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
665 |
"/ reopen the mailbox as a file ... |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
666 |
"/ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
667 |
mbxName := OperatingSystem mailBoxNameOf:mbx. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
668 |
mbxName notNil ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
669 |
super open:mbxName withMode:rwMode. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
670 |
exitAction := [tmpComFile delete]. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
671 |
]. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
672 |
] ifFalse:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
673 |
self setFileDescriptor:myFd mode:rwMode. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
674 |
] |
3296 | 675 |
] ifFalse:[ |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
676 |
lastErrorNumber := OperatingSystem currentErrorNumber. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
677 |
OperatingSystem isVMSlike ifTrue:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
678 |
OperatingSystem destroyMailBox:mbx. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
679 |
tmpComFile delete. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
680 |
] ifFalse:[ |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
681 |
OperatingSystem closeFd:myFd. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
682 |
]. |
3296 | 683 |
]. |
684 |
||
685 |
blocked ifFalse:[ |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
686 |
OperatingSystem unblockInterrupts |
3296 | 687 |
]. |
688 |
||
689 |
lastErrorNumber notNil ifTrue:[ |
|
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
690 |
" |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
691 |
the pipe open failed for some reason ... |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
692 |
... this may be either due to an invalid command string, |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
693 |
or due to the system running out of memory (when forking |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
694 |
the unix process) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
695 |
" |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
696 |
exitAction value. |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
5880
diff
changeset
|
697 |
^ self openError |
3296 | 698 |
]. |
699 |
||
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
700 |
commandString := realCmd. |
5673
58ebbb50cd3a
Set to unbuffered, sincestdio does not work with pipes.
Stefan Vogel <sv@exept.de>
parents:
5624
diff
changeset
|
701 |
|
58ebbb50cd3a
Set to unbuffered, sincestdio does not work with pipes.
Stefan Vogel <sv@exept.de>
parents:
5624
diff
changeset
|
702 |
"stdio lib does not work with blocking pipes and interrupts |
58ebbb50cd3a
Set to unbuffered, sincestdio does not work with pipes.
Stefan Vogel <sv@exept.de>
parents:
5624
diff
changeset
|
703 |
for WIN, Linux, Solaris and probably any other UNIX" |
58ebbb50cd3a
Set to unbuffered, sincestdio does not work with pipes.
Stefan Vogel <sv@exept.de>
parents:
5624
diff
changeset
|
704 |
buffered := false. |
3296 | 705 |
position := 1. |
706 |
hitEOF := false. |
|
707 |
binary := false. |
|
708 |
Lobby register:self. |
|
709 |
||
4202
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
710 |
"Modified: / 23.4.1996 / 17:05:59 / stefan" |
b9f85ebd2e38
generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
711 |
"Modified: / 28.1.1998 / 14:47:34 / md" |
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6267
diff
changeset
|
712 |
"Created: / 19.5.1999 / 12:28:54 / cg" |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6267
diff
changeset
|
713 |
! ! |
613 | 714 |
|
2266 | 715 |
!PipeStream class methodsFor:'documentation'! |
1295 | 716 |
|
717 |
version |
|
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6267
diff
changeset
|
718 |
^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.91 2002-03-04 14:20:44 stefan Exp $' |
1295 | 719 |
! ! |
613 | 720 |
PipeStream initialize! |