PipeStream.st
author Claus Gittinger <cg@exept.de>
Fri, 24 Jul 2015 19:09:44 +0200
changeset 18638 d5624e45f660
parent 17460 27b6fcc56477
child 18640 358b275dced9
child 18782 aa9e2cb1d490
permissions -rw-r--r--
class: PipeStream added: #outputFromCommand:inDirectory: changed: #outputFromCommand:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18638
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
     1
"{ Encoding: utf8 }"
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
     2
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     3
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     4
 COPYRIGHT (c) 1989 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 99
diff changeset
     5
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
"
5388
bef4d52749a4 terminate command on close (also under unix)
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
    14
"{ Package: 'stx:libbasic' }"
bef4d52749a4 terminate command on close (also under unix)
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
    15
17460
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
    16
"{ NameSpace: Smalltalk }"
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
    17
269
93162487a94b *** empty log message ***
claus
parents: 255
diff changeset
    18
NonPositionableExternalStream subclass:#PipeStream
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
    19
	instanceVariableNames:'commandString pid exitStatus exitSema exitAction'
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    20
	classVariableNames:'BrokenPipeSignal'
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    21
	poolDictionaries:''
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    22
	category:'Streams-External'
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    23
!
2
claus
parents: 1
diff changeset
    24
217
a0400fdbc933 *** empty log message ***
claus
parents: 180
diff changeset
    25
!PipeStream primitiveDefinitions!
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    26
%{
17077
8f4500d0df9e include os defs
Claus Gittinger <cg@exept.de>
parents: 16953
diff changeset
    27
#include "stxOSDefs.h"
437
claus
parents: 410
diff changeset
    28
4616
64dd3a9bebf5 *** empty log message ***
ps
parents: 4526
diff changeset
    29
#if defined(WIN32)
793
3d441d66beeb NT changes
Claus Gittinger <cg@exept.de>
parents: 613
diff changeset
    30
# undef UNIX_LIKE
3d441d66beeb NT changes
Claus Gittinger <cg@exept.de>
parents: 613
diff changeset
    31
# define MSDOS_LIKE
3d441d66beeb NT changes
Claus Gittinger <cg@exept.de>
parents: 613
diff changeset
    32
#endif
3d441d66beeb NT changes
Claus Gittinger <cg@exept.de>
parents: 613
diff changeset
    33
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    34
#include <stdio.h>
437
claus
parents: 410
diff changeset
    35
#define _STDIO_H_INCLUDED_
claus
parents: 410
diff changeset
    36
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    37
#include <errno.h>
437
claus
parents: 410
diff changeset
    38
#define _ERRNO_H_INCLUDED_
claus
parents: 410
diff changeset
    39
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    40
#ifndef transputer
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    41
# include <sys/types.h>
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    42
# include <sys/stat.h>
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    43
#endif
230
0300c6797890 interrupt & blocking close
claus
parents: 217
diff changeset
    44
0300c6797890 interrupt & blocking close
claus
parents: 217
diff changeset
    45
/*
0300c6797890 interrupt & blocking close
claus
parents: 217
diff changeset
    46
 * on some systems errno is a macro ... check for it here
0300c6797890 interrupt & blocking close
claus
parents: 217
diff changeset
    47
 */
0300c6797890 interrupt & blocking close
claus
parents: 217
diff changeset
    48
#ifndef errno
0300c6797890 interrupt & blocking close
claus
parents: 217
diff changeset
    49
 extern errno;
0300c6797890 interrupt & blocking close
claus
parents: 217
diff changeset
    50
#endif
0300c6797890 interrupt & blocking close
claus
parents: 217
diff changeset
    51
1663
dd111ec142da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
    52
#ifdef LINUX
dd111ec142da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
    53
# define BUGGY_STDIO_LIB
dd111ec142da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
    54
#endif
dd111ec142da *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1662
diff changeset
    55
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    56
%}
180
c488255bd0be *** empty log message ***
claus
parents: 159
diff changeset
    57
! !
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    58
325
claus
parents: 308
diff changeset
    59
!PipeStream primitiveFunctions!
claus
parents: 308
diff changeset
    60
%{
claus
parents: 308
diff changeset
    61
claus
parents: 308
diff changeset
    62
/*
2925
1a64228425ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    63
 * no longer needed - popen is useless ...
1a64228425ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    64
 */
1a64228425ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    65
#undef NEED_POPEN_WITH_VFORK
1a64228425ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    66
1a64228425ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
    67
/*
325
claus
parents: 308
diff changeset
    68
 * some systems (i.e. ultrix) use fork;
16953
4fb3033a379f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16579
diff changeset
    69
 * we're better off with a popen based on vfork ...
325
claus
parents: 308
diff changeset
    70
 */
claus
parents: 308
diff changeset
    71
#ifdef NEED_POPEN_WITH_VFORK
claus
parents: 308
diff changeset
    72
claus
parents: 308
diff changeset
    73
static int popen_pid = 0;
claus
parents: 308
diff changeset
    74
claus
parents: 308
diff changeset
    75
FILE *
claus
parents: 308
diff changeset
    76
popen(command, type)
claus
parents: 308
diff changeset
    77
/* const */ char *command;
claus
parents: 308
diff changeset
    78
/* const */ char *type;
claus
parents: 308
diff changeset
    79
{
claus
parents: 308
diff changeset
    80
    int pipes[2];
claus
parents: 308
diff changeset
    81
    int itype = (strcmp(type, "w") == 0 ? 1 : 0);
claus
parents: 308
diff changeset
    82
claus
parents: 308
diff changeset
    83
    if (pipe(pipes) == -1)
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    84
	return NULL;
325
claus
parents: 308
diff changeset
    85
claus
parents: 308
diff changeset
    86
    switch (popen_pid = vfork()) {
claus
parents: 308
diff changeset
    87
    case -1:
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    88
	(void)close(pipes[0]);
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    89
	(void)close(pipes[1]);
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    90
	return NULL;
325
claus
parents: 308
diff changeset
    91
claus
parents: 308
diff changeset
    92
    case 0:
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    93
	if (itype) {
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    94
	    dup2(pipes[0], fileno(stdin));
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    95
	    close(pipes[1]);
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    96
	} else {
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    97
	    dup2(pipes[1], fileno(stdout));
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    98
	    close(pipes[0]);
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
    99
	}
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   100
	execl("/bin/sh", "/bin/sh", "-c", command, 0);
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   101
	console_fprintf(stderr, "PipeStream [warning]: execlp failed in popen\n");
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   102
	_exit(-1);
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   103
	/* NOTREACHED */
325
claus
parents: 308
diff changeset
   104
claus
parents: 308
diff changeset
   105
    default:
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   106
	    if (itype) {
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   107
		close(pipes[0]);
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   108
		return fdopen(pipes[1], "w");
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   109
	    } else {
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   110
		close(pipes[1]);
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   111
		return fdopen(pipes[0], "r");
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   112
	    }
325
claus
parents: 308
diff changeset
   113
    }
claus
parents: 308
diff changeset
   114
}
claus
parents: 308
diff changeset
   115
claus
parents: 308
diff changeset
   116
int
claus
parents: 308
diff changeset
   117
pclose(str)
claus
parents: 308
diff changeset
   118
FILE *str;
claus
parents: 308
diff changeset
   119
{
claus
parents: 308
diff changeset
   120
    int pd = 0;
claus
parents: 308
diff changeset
   121
    int status;
claus
parents: 308
diff changeset
   122
    int err;
claus
parents: 308
diff changeset
   123
claus
parents: 308
diff changeset
   124
    err = fclose(str);
claus
parents: 308
diff changeset
   125
claus
parents: 308
diff changeset
   126
    do {
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   127
	if ((pd = wait(&status)) == -1)
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   128
	{
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   129
		err = EOF;
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   130
		break;
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   131
	}
325
claus
parents: 308
diff changeset
   132
    } while (pd !=  popen_pid);
claus
parents: 308
diff changeset
   133
claus
parents: 308
diff changeset
   134
    if (err == EOF)
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   135
	return  -1;
325
claus
parents: 308
diff changeset
   136
claus
parents: 308
diff changeset
   137
    if (status)
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
   138
	status >>= 8;   /* exit status in high byte */
325
claus
parents: 308
diff changeset
   139
claus
parents: 308
diff changeset
   140
    return status;
claus
parents: 308
diff changeset
   141
}
claus
parents: 308
diff changeset
   142
2925
1a64228425ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2896
diff changeset
   143
#endif /* NEED_POPEN_WITH_VFORK */
325
claus
parents: 308
diff changeset
   144
claus
parents: 308
diff changeset
   145
%}
claus
parents: 308
diff changeset
   146
! !
claus
parents: 308
diff changeset
   147
2266
a94af740c68a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   148
!PipeStream class methodsFor:'documentation'!
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   149
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   150
copyright
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   151
"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   152
 COPYRIGHT (c) 1989 by Claus Gittinger
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   153
	      All Rights Reserved
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   154
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   155
 This software is furnished under a license and may be used
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   156
 only in accordance with the terms of that license and with the
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   157
 inclusion of the above copyright notice.   This software may not
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   158
 be provided or otherwise made available to, or used by, any
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   159
 other person.  No title to or ownership of the software is
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   160
 hereby transferred.
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   161
"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   162
!
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   163
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   164
documentation
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   165
"
17460
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
   166
    Pipestreams allow reading or writing from/to a unix or dos command.
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   167
    For example, to get a stream reading the output of an 'ls -l'
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   168
    command, a PipeStream can be created with:
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   169
17460
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
   170
        PipeStream readingFrom:'ls -l'
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   171
17460
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
   172
    the characters of the command's output can be read using the
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
   173
    standard stream messages, such as next, nextLine etc.
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   174
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   175
    Example for writing to a command:
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   176
17460
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
   177
        PipeStream writingTo:'cat >/tmp/x'
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   178
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   179
    Bidirectional pipestreams (supporting both reading an writing) may be used for filters:
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   180
17460
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
   181
        PipeStream bidirectionalFor:'sed -e ''s/Hello/Greetings/'''
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   182
1662
ce26ca3d837c linux stdio does not work with buffered pipes
Claus Gittinger <cg@exept.de>
parents: 1648
diff changeset
   183
    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
   184
    buggy (trying to restart the read ...)
ce26ca3d837c linux stdio does not work with buffered pipes
Claus Gittinger <cg@exept.de>
parents: 1648
diff changeset
   185
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   186
    [author:]
17460
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
   187
        Claus Gittinger
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   188
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   189
    [see also:]
17460
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
   190
        ExternalStream FileStream Socket
27b6fcc56477 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17077
diff changeset
   191
        OperatingSystem
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   192
"
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   193
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   194
2266
a94af740c68a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   195
!PipeStream class methodsFor:'initialization'!
2
claus
parents: 1
diff changeset
   196
claus
parents: 1
diff changeset
   197
initialize
claus
parents: 1
diff changeset
   198
    "setup the signal"
claus
parents: 1
diff changeset
   199
57
db9677479d35 *** empty log message ***
claus
parents: 49
diff changeset
   200
    BrokenPipeSignal isNil ifTrue:[
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   201
	BrokenPipeSignal := WriteError newSignalMayProceed:true.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   202
	BrokenPipeSignal nameClass:self message:#brokenPipeSignal.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   203
	BrokenPipeSignal notifierString:'write on a pipe with no one to read'.
57
db9677479d35 *** empty log message ***
claus
parents: 49
diff changeset
   204
    ]
2
claus
parents: 1
diff changeset
   205
! !
claus
parents: 1
diff changeset
   206
2266
a94af740c68a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   207
!PipeStream class methodsFor:'instance creation'!
2
claus
parents: 1
diff changeset
   208
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   209
bidirectionalFor:commandString
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   210
    "create and return a new bidirectonal pipeStream which can both be written to
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   211
     and read from the unix command given by commandString.
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   212
     The commands error output is send to my own error output."
2
claus
parents: 1
diff changeset
   213
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   214
    ^ self
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   215
	bidirectionalFor:commandString
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   216
	errorDisposition:#stderr
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   217
	inDirectory:nil
1648
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   218
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   219
    "
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   220
	|p|
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   221
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   222
	p := PipeStream bidirectionalFor:'cat -u'.
18638
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   223
	p nextPutAll:'Wer ist der Bürgermeister von Wesel'; cr.
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   224
	Transcript showCR:p nextLine.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   225
	p close
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   226
    "
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   227
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   228
    "
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   229
	|p|
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   230
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   231
	p := PipeStream bidirectionalFor:'sed -e ''s/Hello/Greetings/'''.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   232
	p nextPutAll:'Hello world'; cr.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   233
	p shutDownOutput.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   234
	Transcript showCR:p nextLine.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   235
	p close
1648
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   236
    "
9313
297699a317d3 comment/example
Stefan Vogel <sv@exept.de>
parents: 9193
diff changeset
   237
297699a317d3 comment/example
Stefan Vogel <sv@exept.de>
parents: 9193
diff changeset
   238
    "
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   239
	|p|
9313
297699a317d3 comment/example
Stefan Vogel <sv@exept.de>
parents: 9193
diff changeset
   240
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   241
	p := PipeStream bidirectionalFor:'wc'.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   242
	p nextPutAll:'Hello world'; cr.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   243
	p shutDownOutput.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   244
	Transcript showCR:p nextLine.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   245
	p close
9313
297699a317d3 comment/example
Stefan Vogel <sv@exept.de>
parents: 9193
diff changeset
   246
    "
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   247
!
1648
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   248
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   249
bidirectionalFor:commandString errorDisposition:errorDisposition inDirectory:aDirectory
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   250
    "create and return a new bidirectonal pipeStream which can both be written to
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   251
     and read from the unix command given by commandString.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   252
     The directory will be changed to aDirectory while
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   253
     executing the command. Use this if a command is to be
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   254
     executed in another directory, to avoid any OS dependencies
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   255
     in your code.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   256
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   257
     errorDisposition may be one of #discard, #inline or #stderr (default).
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   258
     #discard causes stderr to be discarded (/dev/null),
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   259
     #inline causes it to be written to smalltalks own stdout and
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   260
     #stderr causes it to be written to smalltalks own stderr.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   261
     Nil is treated like #stderr"
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   262
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   263
    ^ self basicNew
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   264
	openPipeFor:commandString
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   265
	withMode:#'r+'
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   266
	errorDisposition:errorDisposition
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   267
	inDirectory:aDirectory
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   268
!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   269
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   270
readingFrom:commandString
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   271
    "create and return a new pipeStream which can read from the unix command
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   272
     given by commandString.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   273
     The commands error output is send to my own error output."
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   274
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   275
    ^ self
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   276
	readingFrom:commandString
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   277
	errorDisposition:#stderr
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   278
	inDirectory:nil
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   279
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   280
    "unix:
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   281
	PipeStream readingFrom:'ls -l'.
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   282
    "
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   283
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   284
    "
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   285
	|p|
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   286
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   287
	p := PipeStream readingFrom:'ls -l'.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   288
	Transcript showCR:p nextLine.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   289
	p close
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   290
    "
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   291
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   292
    "
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   293
	|s|
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   294
	s := PipeStream readingFrom:'sh -c sleep\ 600'.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   295
	(Delay forSeconds:2) wait.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   296
	s shutDown
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   297
    "
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   298
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   299
    "vms:
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   300
	PipeStream readingFrom:'dir'.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   301
    "
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   302
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   303
    "
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   304
	|p|
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   305
	p := PipeStream readingFrom:'dir'.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   306
	Transcript showCR:p nextLine.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   307
	p close
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   308
    "
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   309
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   310
    "msdos:
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   311
	PipeStream readingFrom:'dir'.
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   312
    "
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   313
    "
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   314
	|p|
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   315
	p := PipeStream readingFrom:'dir'.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   316
	Transcript showCR:p nextLine.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   317
	p close
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   318
    "
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   319
1648
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   320
    "Modified: 24.4.1996 / 09:09:25 / stefan"
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   321
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   322
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   323
readingFrom:commandString errorDisposition:errorDisposition inDirectory:aDirectory
2985
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   324
    "similar to #readingFrom, but changes the directory while
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   325
     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
   326
     executed in another directory, to avoid any OS dependencies
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   327
     in your code.
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   328
     errorDisposition may be one of #discard, #inline or #stderr (default).
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   329
     #discard causes stderr to be discarded (/dev/null),
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   330
     #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
   331
     #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
   332
     Nil is treated like #stderr"
2985
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   333
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   334
    ^ self basicNew
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   335
	openPipeFor:commandString
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   336
	withMode:#r
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   337
	errorDisposition:errorDisposition
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   338
	inDirectory:aDirectory
2985
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   339
!
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   340
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   341
readingFrom:commandString inDirectory:aDirectory
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   342
    "similar to #readingFrom, but changes the directory while
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   343
     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
   344
     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
   345
     in your code.
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   346
     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
   347
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   348
     ^ self
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   349
	readingFrom:commandString
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   350
	errorDisposition:#stderr
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   351
	inDirectory:aDirectory
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   352
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   353
    " UNIX:
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   354
	|p|
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   355
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   356
	p := PipeStream readingFrom:'ls -l' inDirectory:'/etc'.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   357
	Transcript showCR:p upToEnd.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   358
	p close
9193
47ffbf7b9ee8 comment
Claus Gittinger <cg@exept.de>
parents: 8976
diff changeset
   359
    "
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   360
    "WINDOOF:
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   361
	|p|
9193
47ffbf7b9ee8 comment
Claus Gittinger <cg@exept.de>
parents: 8976
diff changeset
   362
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   363
	p := PipeStream readingFrom:'dir'.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   364
	Transcript showCR:p upToEnd.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   365
	p close
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   366
   "
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   367
!
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   368
2
claus
parents: 1
diff changeset
   369
writingTo:commandString
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   370
    "create and return a new pipeStream which can write to the unix command
a27a279701f8 Initial revision
claus
parents:
diff changeset
   371
     given by command."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   372
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   373
    ^ self
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   374
	writingTo:commandString errorDisposition:#stderr inDirectory:nil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   375
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   376
    "unix:
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   377
	 PipeStream writingTo:'sort'
2966
856dfc8a294a lots of VMS changes
Claus Gittinger <cg@exept.de>
parents: 2961
diff changeset
   378
    "
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   379
!
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   380
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   381
writingTo:commandString errorDisposition:errorDisposition inDirectory:aDirectory
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   382
    "similar to #writingTo, but changes the directory while
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   383
     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
   384
     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
   385
     in your code.
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   386
     errorDisposition may be one of #discard, #inline or #stderr (default).
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   387
     #discard causes stderr to be discarded (/dev/null),
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   388
     #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
   389
     #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
   390
     Nil is treated like #stderr"
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   391
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   392
    ^ self basicNew
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   393
	openPipeFor:commandString
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   394
	withMode:#w
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   395
	errorDisposition:errorDisposition
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   396
	inDirectory:aDirectory
4526
a42dc8e09586 errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
   397
!
a42dc8e09586 errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
   398
a42dc8e09586 errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
   399
writingTo:commandString inDirectory:aDirectory
a42dc8e09586 errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
   400
    "create and return a new pipeStream which can write to the unix command
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   401
     given by commandString. The command is executed in the given directory."
4526
a42dc8e09586 errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
   402
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   403
    ^ self
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   404
	writingTo:commandString errorDisposition:#stderr inDirectory:aDirectory
4526
a42dc8e09586 errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
   405
a42dc8e09586 errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
   406
    "unix:
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   407
	 PipeStream writingTo:'sort'
4526
a42dc8e09586 errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
   408
    "
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   409
! !
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   410
2266
a94af740c68a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   411
!PipeStream class methodsFor:'Signal constants'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   412
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   413
brokenPipeSignal
2985
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   414
    "return the signal used to handle SIGPIPE unix-signals.
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   415
     Since SIGPIPE is asynchronous, we can't decide which smalltalk process
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   416
     should handle BrokenPipeSignal. So the system doesn't raise
2985
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   417
     BrokenPipeSignal for SIGPIPE any longer."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   418
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   419
    ^ BrokenPipeSignal
2985
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   420
eff9e86dd2f9 New method #readingFrom:errorDisposition:inDirectory.
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   421
    "Modified: 24.9.1997 / 09:43:23 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   422
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   423
16579
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   424
!PipeStream class methodsFor:'utilities'!
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   425
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   426
outputFromCommand:aCommand
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   427
    "open a pipe reading from aCommand and return the complete output as a string.
18638
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   428
     If the command cannot be executed, return nil.
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   429
     The command's current directory will be the smalltalk current directory."
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   430
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   431
    ^ self outputFromCommand:aCommand inDirectory:nil
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   432
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   433
    "
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   434
     PipeStream outputFromCommand:'ls -l'
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   435
    "
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   436
!
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   437
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   438
outputFromCommand:aCommand inDirectory:aDirectoryOrNil
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   439
    "open a pipe reading from aCommand and return the complete output as a string.
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   440
     If the command cannot be executed, return nil.
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   441
     The current directory of the command will be aDirectoryOrNil or the smalltalk's current directory (if nil)"
16579
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   442
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   443
    |p cmdOutput|
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   444
18638
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   445
    p := self readingFrom:aCommand inDirectory:aDirectoryOrNil.
16579
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   446
    p isNil ifTrue:[^ nil].
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   447
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   448
    [
18638
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   449
        cmdOutput := p contentsAsString.
16579
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   450
    ] ensure:[
18638
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   451
        p close.
16579
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   452
    ].
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   453
    ^ cmdOutput
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   454
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   455
    "
18638
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   456
     PipeStream outputFromCommand:'ls -l' inDirectory:nil
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   457
     PipeStream outputFromCommand:'ls -l' inDirectory:'/'
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   458
     PipeStream outputFromCommand:'ls -l' inDirectory:'/etc'
16579
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   459
    "
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   460
! !
3d51a7434f06 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 16339
diff changeset
   461
99
afba01fbe15c added access method for commandString
claus
parents: 93
diff changeset
   462
!PipeStream methodsFor:'accessing'!
afba01fbe15c added access method for commandString
claus
parents: 93
diff changeset
   463
afba01fbe15c added access method for commandString
claus
parents: 93
diff changeset
   464
commandString
afba01fbe15c added access method for commandString
claus
parents: 93
diff changeset
   465
    "return the command string"
afba01fbe15c added access method for commandString
claus
parents: 93
diff changeset
   466
afba01fbe15c added access method for commandString
claus
parents: 93
diff changeset
   467
    ^ commandString
1648
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   468
!
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   469
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   470
exitStatus
10343
c48f0a54ef69 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9313
diff changeset
   471
    "return the exitStatus"
1648
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   472
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   473
    ^ exitStatus
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   474
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   475
    "Created: 28.12.1995 / 14:54:41 / stefan"
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   476
!
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   477
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   478
pid
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   479
    "return pid"
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   480
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   481
    ^ pid
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   482
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   483
    "Created: 28.12.1995 / 14:54:30 / stefan"
99
afba01fbe15c added access method for commandString
claus
parents: 93
diff changeset
   484
! !
afba01fbe15c added access method for commandString
claus
parents: 93
diff changeset
   485
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   486
!PipeStream methodsFor:'closing'!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   487
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   488
shutDown
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   489
    "close the Stream and terminate the command"
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   490
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   491
    Lobby unregister:self.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   492
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   493
    "terminate first under windows"
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   494
    OperatingSystem isMSDOSlike ifTrue:[
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   495
	self terminatePipeCommand.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   496
	self closeFileDescriptor.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   497
	^ self.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   498
    ].
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   499
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   500
    "terminate last under unix"
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   501
    self closeFileDescriptor.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   502
    self terminatePipeCommand.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   503
!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   504
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   505
shutDownOutput
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   506
    "signal to the pipestream's command, that no more data will be sent"
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   507
8976
2ff451956d48 #shutDownOutput do nothing (ignore errors), if pipe is closed
Stefan Vogel <sv@exept.de>
parents: 8969
diff changeset
   508
    |fd|
2ff451956d48 #shutDownOutput do nothing (ignore errors), if pipe is closed
Stefan Vogel <sv@exept.de>
parents: 8969
diff changeset
   509
2ff451956d48 #shutDownOutput do nothing (ignore errors), if pipe is closed
Stefan Vogel <sv@exept.de>
parents: 8969
diff changeset
   510
    self isOpen ifTrue:[
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   511
	fd := self fileDescriptor.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   512
	fd notNil ifTrue:[
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   513
	    OperatingSystem shutdownBidirectionalPipeOutput:fd.
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   514
	].
8976
2ff451956d48 #shutDownOutput do nothing (ignore errors), if pipe is closed
Stefan Vogel <sv@exept.de>
parents: 8969
diff changeset
   515
    ].
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   516
! !
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   517
5243
d3b509746522 category change
Claus Gittinger <cg@exept.de>
parents: 5205
diff changeset
   518
!PipeStream methodsFor:'finalization'!
d3b509746522 category change
Claus Gittinger <cg@exept.de>
parents: 5205
diff changeset
   519
6439
0f841258ec4a Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 6267
diff changeset
   520
finalize
5243
d3b509746522 category change
Claus Gittinger <cg@exept.de>
parents: 5205
diff changeset
   521
    "redefined to avoid blocking in close."
d3b509746522 category change
Claus Gittinger <cg@exept.de>
parents: 5205
diff changeset
   522
d3b509746522 category change
Claus Gittinger <cg@exept.de>
parents: 5205
diff changeset
   523
    self shutDown
d3b509746522 category change
Claus Gittinger <cg@exept.de>
parents: 5205
diff changeset
   524
! !
d3b509746522 category change
Claus Gittinger <cg@exept.de>
parents: 5205
diff changeset
   525
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   526
!PipeStream protectedMethodsFor:'private'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   527
a27a279701f8 Initial revision
claus
parents:
diff changeset
   528
closeFile
1648
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   529
    "low level close
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   530
     This waits for the command to finish.
230
0300c6797890 interrupt & blocking close
claus
parents: 217
diff changeset
   531
     Use shutDown for a fast (nonBlocking) close."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   532
12395
1db7ea277c93 filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 11083
diff changeset
   533
    handle notNil ifTrue:[
16953
4fb3033a379f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16579
diff changeset
   534
	super closeFile.
16339
26dfaf4606d5 class: PipeStream
Stefan Vogel <sv@exept.de>
parents: 15436
diff changeset
   535
"/        OperatingSystem isMSDOSlike ifTrue:[
26dfaf4606d5 class: PipeStream
Stefan Vogel <sv@exept.de>
parents: 15436
diff changeset
   536
"/            self terminatePipeCommand.
26dfaf4606d5 class: PipeStream
Stefan Vogel <sv@exept.de>
parents: 15436
diff changeset
   537
"/        ].
3834
93ec07316a98 oops - must nil pid when terminating the process
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
   538
16953
4fb3033a379f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16579
diff changeset
   539
	handle := nil.
4fb3033a379f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16579
diff changeset
   540
	pid notNil ifTrue:[
4fb3033a379f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16579
diff changeset
   541
	    "/ wait for the pipe-command to terminate.
4fb3033a379f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16579
diff changeset
   542
	    self waitForPipeCommandWithTimeout:nil.
4fb3033a379f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16579
diff changeset
   543
	].
1648
faa891d2c1b0 Use OperatingSystem executeCommand:... instead of popen().
Stefan Vogel <sv@exept.de>
parents: 1295
diff changeset
   544
    ].
3833
3ae90f8da01a terminate process BEFORE closing the pipe under win32
Claus Gittinger <cg@exept.de>
parents: 3791
diff changeset
   545
3834
93ec07316a98 oops - must nil pid when terminating the process
Claus Gittinger <cg@exept.de>
parents: 3833
diff changeset
   546
    "Modified: / 12.9.1998 / 16:51:04 / cg"
12712
c1b3b5846541 Make most win32 wrap calls non-interruptable
Stefan Vogel <sv@exept.de>
parents: 12548
diff changeset
   547
! !
c1b3b5846541 Make most win32 wrap calls non-interruptable
Stefan Vogel <sv@exept.de>
parents: 12548
diff changeset
   548
c1b3b5846541 Make most win32 wrap calls non-interruptable
Stefan Vogel <sv@exept.de>
parents: 12548
diff changeset
   549
!PipeStream methodsFor:'private'!
369
claus
parents: 362
diff changeset
   550
claus
parents: 362
diff changeset
   551
closeFileDescriptor
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   552
    "alternative very low level close
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   553
     This closes the underlying OS-fileDescriptor
369
claus
parents: 362
diff changeset
   554
     - and will NOT write any buffered data to the stream.
claus
parents: 362
diff changeset
   555
     You have been warned."
claus
parents: 362
diff changeset
   556
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   557
    |action|
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   558
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   559
%{
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   560
#if !defined(transputer)
369
claus
parents: 362
diff changeset
   561
    OBJ fp;
claus
parents: 362
diff changeset
   562
    FILE *f;
4616
64dd3a9bebf5 *** empty log message ***
ps
parents: 4526
diff changeset
   563
    extern close();
6267
10016cc16511 pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents: 5880
diff changeset
   564
    int retVal;
369
claus
parents: 362
diff changeset
   565
12395
1db7ea277c93 filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 11083
diff changeset
   566
    if ((fp = __INST(handle)) != nil) {
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   567
	__INST(handle) = nil;
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   568
	f = __FILEVal(fp);
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   569
	if (@global(FileOpenTrace) == true) {
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   570
	    console_fprintf(stderr, "close [PipeStream] %"_lx_" fd=%d\n", (INT)f, fileno(f));
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   571
	}
3744
e2c57149f3b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
   572
#ifdef WIN32
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   573
	do {
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   574
	    __threadErrno = 0;
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   575
	    retVal = __STX_C_NOINT_CALL1( "close", (void*)close, (void*)fileno(f) );
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   576
	} while ((retVal < 0) && (__threadErrno == EINTR));
3744
e2c57149f3b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
   577
#else
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   578
	__BEGIN_INTERRUPTABLE__
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   579
	close(fileno(f));
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   580
	__END_INTERRUPTABLE__
3744
e2c57149f3b4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
   581
#endif
369
claus
parents: 362
diff changeset
   582
    }
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   583
#endif /* not transputer  */
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   584
%}.
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   585
    exitAction notNil ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   586
	action := exitAction.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   587
	exitAction := nil.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   588
	action value.
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   589
    ]
12712
c1b3b5846541 Make most win32 wrap calls non-interruptable
Stefan Vogel <sv@exept.de>
parents: 12548
diff changeset
   590
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   591
2969
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   592
exitAction:aBlock
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   593
    "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
   594
     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
   595
     (see readingFrom:inDirectory:)"
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   596
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   597
    exitAction := aBlock
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   598
!
1fcf6dfb6004 VMS pipes in another directory
Claus Gittinger <cg@exept.de>
parents: 2966
diff changeset
   599
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   600
openPipeFor:aCommandString withMode:rwMode errorDisposition:errorDisposition inDirectory:aDirectory
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   601
    "open a pipe to the OS command in commandString;
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   602
     rwMode may be 'r' or 'w' or 'r+'.
5481
680d6de80808 comment
Claus Gittinger <cg@exept.de>
parents: 5456
diff changeset
   603
     errorDisposition controls where the stdErr output should go,
680d6de80808 comment
Claus Gittinger <cg@exept.de>
parents: 5456
diff changeset
   604
     and may be one of #discard, #inline or #stderr (default).
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   605
     #discard causes stderr to be discarded (/dev/null),
5481
680d6de80808 comment
Claus Gittinger <cg@exept.de>
parents: 5456
diff changeset
   606
     #inline causes it to be written to smalltalks own stdout and
680d6de80808 comment
Claus Gittinger <cg@exept.de>
parents: 5456
diff changeset
   607
     #stderr causes it to be written to smalltalks own stderr.
680d6de80808 comment
Claus Gittinger <cg@exept.de>
parents: 5456
diff changeset
   608
     Nil is treated like #stderr"
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   609
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   610
    |blocked pipeFdArray execFdArray execFd myFd shellAndArgs
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   611
     shellPath shellArgs mbx mbxName
14436
c65fa56075a4 changed: #openPipeFor:withMode:errorDisposition:inDirectory:
Stefan Vogel <sv@exept.de>
parents: 12712
diff changeset
   612
     realCmd execDirectory tmpComFile nullOutput resultPid errorNumber|
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   613
12395
1db7ea277c93 filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents: 11083
diff changeset
   614
    handle notNil ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   615
	"the pipe was already open ...
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   616
	 this should (can) not happen."
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   617
	^ self errorAlreadyOpen
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   618
    ].
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   619
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   620
    rwMode = #r ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   621
	mode := #readonly. didWrite := false.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   622
    ] ifFalse:[rwMode = #'r+' ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   623
	mode := #readwrite. didWrite := true.
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   624
    ] ifFalse:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   625
	mode := #writeonly. didWrite := true.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   626
    ]].
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   627
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   628
    lastErrorNumber := nil.
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   629
    exitStatus := nil.
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   630
    exitSema := Semaphore new name:'pipe exitSema'.
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   631
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   632
    realCmd := aCommandString.
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   633
    execDirectory := aDirectory.
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   634
    execFdArray := #(0 1 2) copy.
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   635
3791
76ea6c85ca1f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
   636
    OperatingSystem isVMSlike ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   637
	"/
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   638
	"/ the generated COM-file includes a 'set default'
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   639
	"/
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   640
	tmpComFile := OperatingSystem createCOMFileForVMSCommand:aCommandString in:aDirectory.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   641
	realCmd := '@' , tmpComFile osName.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   642
	execDirectory := nil.
4616
64dd3a9bebf5 *** empty log message ***
ps
parents: 4526
diff changeset
   643
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   644
	mbx := OperatingSystem createMailBox.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   645
	mbx isNil ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   646
	    lastErrorNumber := errorNumber := OperatingSystem currentErrorNumber.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   647
	    tmpComFile delete.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   648
	    ^ self openError:errorNumber.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   649
	].
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   650
	mbxName := OperatingSystem mailBoxNameOf:mbx.
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   651
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   652
	"/ 'mailBox is ' print. mbx print. ' name is ' print. mbxName printCR.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   653
	shellPath := ''.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   654
	shellArgs := realCmd.
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   655
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   656
	rwMode = #r ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   657
	    "redirect stdout of subprocess to write to mailbox"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   658
	    execFdArray at:2 put:mbx.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   659
	] ifFalse:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   660
	    "redirect stdin of subprocess to read from mailbox"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   661
	    execFdArray at:1 put:mbx.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   662
	].
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   663
    ] ifFalse:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   664
	shellAndArgs := OperatingSystem commandAndArgsForOSCommand:realCmd.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   665
	shellPath := shellAndArgs at:1.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   666
	shellArgs := shellAndArgs at:2.
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   667
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   668
	mode == #readwrite ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   669
	    pipeFdArray := OperatingSystem makeBidirectionalPipe.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   670
	    pipeFdArray isNil ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   671
		lastErrorNumber := errorNumber := OperatingSystem currentErrorNumber.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   672
		^ self openError:errorNumber.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   673
	    ].
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   674
	    myFd := pipeFdArray at:1.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   675
	    execFd := pipeFdArray at:2.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   676
	    execFdArray at:1 put:execFd.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   677
	    execFdArray at:2 put:execFd.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   678
	] ifFalse:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   679
	    pipeFdArray := OperatingSystem makePipe.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   680
	    pipeFdArray isNil ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   681
		lastErrorNumber := errorNumber := OperatingSystem currentErrorNumber.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   682
		^ self openError:errorNumber.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   683
	    ].
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   684
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   685
	    mode == #readonly ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   686
		"redirect stdout of subprocess to write to pipe"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   687
		myFd := pipeFdArray at:1.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   688
		execFd := pipeFdArray at:2.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   689
		execFdArray at:2 put:execFd.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   690
	    ] ifFalse:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   691
		"redirect stdin of subprocess to read from pipe"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   692
		myFd := pipeFdArray at:2.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   693
		execFd := pipeFdArray at:1.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   694
		execFdArray at:1 put:execFd.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   695
	    ].
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   696
	].
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   697
    ].
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   698
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   699
    errorDisposition == #discard ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   700
	nullOutput := Filename nullDevice writeStream.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   701
	execFdArray at:3 put:nullOutput fileDescriptor
11083
988c0b2e8a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10408
diff changeset
   702
    ] ifFalse:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   703
	(errorDisposition == #inline or:[errorDisposition == #stdout]) ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   704
	    execFdArray at:3 put:1
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   705
	] ifFalse:[
11083
988c0b2e8a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10408
diff changeset
   706
"/            errorDisposition isStream ifTrue:[
988c0b2e8a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10408
diff changeset
   707
"/self halt.
988c0b2e8a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10408
diff changeset
   708
"/            ].
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   709
	].
11083
988c0b2e8a26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10408
diff changeset
   710
    ].
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   711
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   712
    "/ must block here, to avoid races due to early finishing
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   713
    "/ subprocesses ...
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   714
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   715
    blocked := OperatingSystem blockInterrupts.
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   716
10363
5cf689c14989 Fix race condition in PipeStream.
Stefan Vogel <sv@exept.de>
parents: 10343
diff changeset
   717
    "beware: pid may change if subprocess is fast"
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   718
    pid := resultPid :=  Processor
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   719
	       monitor:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   720
		  OperatingSystem
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   721
		      exec:shellPath
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   722
		      withArguments:shellArgs
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   723
		      environment:nil
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   724
		      fileDescriptors:execFdArray
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   725
		      fork:true
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   726
		      newPgrp:true
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   727
		      inDirectory:execDirectory.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   728
	       ]
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   729
	       action:[:status |
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   730
		  status stillAlive ifFalse:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   731
		      exitStatus := status.
8969
978613904d0b For writing Pipestreams: close write side of filedescriptor, when
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
   732
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   733
		      "writing doesn't make sense - there is no reader any longer"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   734
		      mode == #readwrite ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   735
			  "... but allow to read the rest of the command's output"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   736
			  self shutDownOutput.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   737
		      ] ifFalse:[mode == #writeonly ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   738
			  self closeFileDescriptor.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   739
		      ]].
10408
8027bf22ae31 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10363
diff changeset
   740
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   741
		      OperatingSystem closePid:pid.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   742
		      pid := nil.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   743
		      exitSema signal.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   744
		  ].
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   745
	       ].
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   746
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   747
    "subprocess has been created.
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   748
     close unused filedescriptors"
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   749
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7060
diff changeset
   750
    execFd notNil ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   751
	OperatingSystem closeFd:execFd.
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   752
    ].
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   753
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   754
    nullOutput notNil ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   755
	nullOutput close
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   756
    ].
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   757
10363
5cf689c14989 Fix race condition in PipeStream.
Stefan Vogel <sv@exept.de>
parents: 10343
diff changeset
   758
    resultPid notNil ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   759
	"successfull creation of subprocesss"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   760
	OperatingSystem isVMSlike ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   761
	    "/
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   762
	    "/ reopen the mailbox as a file ...
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   763
	    "/
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   764
	    mbxName := OperatingSystem mailBoxNameOf:mbx.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   765
	    mbxName notNil ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   766
		super open:mbxName withMode:rwMode.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   767
		exitAction := [tmpComFile delete].
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   768
	    ].
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   769
	] ifFalse:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   770
	    self setFileDescriptor:myFd mode:rwMode.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   771
	    handleType := #pipeFilePointer.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   772
	]
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   773
    ] ifFalse:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   774
	"creation of subprocesss failed"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   775
	lastErrorNumber := OperatingSystem currentErrorNumber.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   776
	OperatingSystem isVMSlike ifTrue:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   777
	    OperatingSystem destroyMailBox:mbx.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   778
	    tmpComFile delete.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   779
	] ifFalse:[
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   780
	    OperatingSystem closeFd:myFd.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   781
	].
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   782
    ].
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   783
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   784
    blocked ifFalse:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   785
	OperatingSystem unblockInterrupts
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   786
    ].
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   787
10363
5cf689c14989 Fix race condition in PipeStream.
Stefan Vogel <sv@exept.de>
parents: 10343
diff changeset
   788
    (resultPid isNil or:[lastErrorNumber notNil]) ifTrue:[
15436
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   789
	"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   790
	 the pipe open failed for some reason ...
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   791
	 ... this may be either due to an invalid command string,
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   792
	 or due to the system running out of memory (when forking
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   793
	 the unix process)
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   794
	"
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   795
	exitAction value.
c3fbdee3669d casts for 64bit in printfs
Claus Gittinger <cg@exept.de>
parents: 15359
diff changeset
   796
	^ self openError:lastErrorNumber.
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   797
    ].
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   798
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   799
    commandString := realCmd.
5673
58ebbb50cd3a Set to unbuffered, sincestdio does not work with pipes.
Stefan Vogel <sv@exept.de>
parents: 5624
diff changeset
   800
58ebbb50cd3a Set to unbuffered, sincestdio does not work with pipes.
Stefan Vogel <sv@exept.de>
parents: 5624
diff changeset
   801
    "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
   802
     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
   803
    buffered := false.
15359
060c677e3e92 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 14436
diff changeset
   804
    position := 0.
3296
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   805
    hitEOF := false.
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   806
    binary := false.
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   807
    Lobby register:self.
bd2da537678b md's WIN32 changes
Claus Gittinger <cg@exept.de>
parents: 3196
diff changeset
   808
4202
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   809
    "Modified: / 23.4.1996 / 17:05:59 / stefan"
b9f85ebd2e38 generalized errorDisposition (for other OS's);
Claus Gittinger <cg@exept.de>
parents: 4125
diff changeset
   810
    "Modified: / 28.1.1998 / 14:47:34 / md"
6439
0f841258ec4a Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 6267
diff changeset
   811
    "Created: / 19.5.1999 / 12:28:54 / cg"
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   812
!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   813
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   814
terminatePipeCommand
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   815
    |tpid|
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   816
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   817
    (tpid := pid) notNil ifTrue:[
16953
4fb3033a379f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16579
diff changeset
   818
	OperatingSystem terminateProcessGroup:tpid.
4fb3033a379f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16579
diff changeset
   819
	OperatingSystem terminateProcess:tpid.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   820
    ].
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   821
!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   822
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   823
waitForPipeCommandWithTimeout:seconds
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   824
    "wait for the pipe command to terminate itself.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   825
     Return true, if a timeout occurred."
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   826
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   827
    pid notNil ifTrue:[
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   828
	[
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   829
	    pid notNil ifTrue:[
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   830
		exitSema waitWithTimeout:seconds.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   831
	    ]
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   832
	] valueUninterruptably
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   833
    ].
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8520
diff changeset
   834
    ^ pid notNil
6439
0f841258ec4a Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 6267
diff changeset
   835
! !
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   836
2266
a94af740c68a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   837
!PipeStream class methodsFor:'documentation'!
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   838
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   839
version
18638
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   840
    ^ '$Header$'
12712
c1b3b5846541 Make most win32 wrap calls non-interruptable
Stefan Vogel <sv@exept.de>
parents: 12548
diff changeset
   841
!
c1b3b5846541 Make most win32 wrap calls non-interruptable
Stefan Vogel <sv@exept.de>
parents: 12548
diff changeset
   842
c1b3b5846541 Make most win32 wrap calls non-interruptable
Stefan Vogel <sv@exept.de>
parents: 12548
diff changeset
   843
version_CVS
18638
d5624e45f660 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 17460
diff changeset
   844
    ^ '$Header$'
1295
83f594f05c52 documentation
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   845
! !
7027
0efa9d55fa04 Remove unused method var
Stefan Vogel <sv@exept.de>
parents: 6487
diff changeset
   846
15359
060c677e3e92 class: PipeStream
Claus Gittinger <cg@exept.de>
parents: 14436
diff changeset
   847
613
0af19c3594fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 582
diff changeset
   848
PipeStream initialize!