OSProcess.st
author Stefan Vogel <sv@exept.de>
Tue, 03 Jul 2018 23:38:44 +0200
changeset 23189 15ea23cfead5
parent 23184 5527a9f0dfd4
child 23201 70c0a58e1ab5
permissions -rw-r--r--
#FEATURE by stefan class: Set added: #addOrReplace:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23182
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
     1
"{ Encoding: utf8 }"
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
     2
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     3
"{ Package: 'stx:libbasic' }"
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     4
19286
9e8eea97fd57 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 13313
diff changeset
     5
"{ NameSpace: Smalltalk }"
9e8eea97fd57 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 13313
diff changeset
     6
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
     7
Object subclass:#OSProcess
23035
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
     8
	instanceVariableNames:'pid command environment directory inStream outStream errorStream
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
     9
		auxStream showWindow lineWise newPgrp exitStatus finishSema
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
    10
		shufflerProcesses streamsToClose terminateActionBlock'
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
    11
	classVariableNames:''
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
    12
	poolDictionaries:''
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
    13
	category:'System-Support'
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    14
!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    15
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
    16
OSProcess subclass:#RemoteOSProcess
23035
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
    17
	instanceVariableNames:'host'
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
    18
	classVariableNames:'MethodPerHost'
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
    19
	poolDictionaries:''
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
    20
	privateIn:OSProcess
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
    21
!
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
    22
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    23
!OSProcess class methodsFor:'documentation'!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    24
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    25
documentation
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    26
"
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
    27
    Instances of OSProcess represent operating system processes that can be executed.
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    28
    (as opposed to Smalltalk processes).
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    29
    Both local and remote processes are suported.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    30
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    31
    commandString:
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    32
     If command is a String, the commandString is passed to a shell for execution
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    33
     - see the description of 'sh -c' in your UNIX manual ('cmd.exe' in your Windows manual).
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    34
     Regular input/output redirection and pipes etc. are supported as supported by
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    35
     the underlying OS's command interpreter (i.e. some limits apply to MSDOS)
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    36
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    37
     With an empty command, the shell will read commands from the passed input stream.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    38
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    39
     If command is an Array, the first element is the command to be executed,
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    40
     and the other elements are the arguments to the command. 
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    41
     No shell is invoked in this case. Any redirection or piping can then be done
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    42
     by Smalltalk code (including piping through smalltalk streams & filters).
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    43
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    44
    [author:]
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    45
        Stefan Vogel (stefan@zwerg)
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    46
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    47
    [instance variables:]
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    48
        pid         SmallInteger    the process id
21182
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
    49
        command     String          the command line of the running command.
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    50
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    51
    [class variables:]
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    52
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    53
    [see also:]
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    54
        Process
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    55
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
    56
"
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
    57
!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
    58
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
    59
examples
21512
a78759923d34 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21332
diff changeset
    60
"
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    61
  send command's output to the Transcript:
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    62
                                                            [exBegin]
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    63
    OSProcess new 
22986
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
    64
        terminateActionBlock:[:status | Transcript showCR:status. Transcript showCR:status isError];
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
    65
        command:'lsxxxx -l';
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    66
        outStream:Transcript;
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    67
        lineWise:true;
22986
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
    68
        startProcess.
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    69
                                                            [exEnd]
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    70
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    71
  send command's output to my stdout (see console):
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    72
                                                            [exBegin]
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    73
    OSProcess new 
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    74
        command:'ls -l';
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    75
        outStream:Stdout;
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    76
        execute.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    77
                                                            [exEnd]
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    78
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    79
  send command's output to a Smalltalk stream:
22197
444d71c29720 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22181
diff changeset
    80
                                                            [exBegin]
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
    81
    |outStream|
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
    82
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
    83
    outStream := '' writeStream.
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
    84
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
    85
    OSProcess new 
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
    86
        command:'ls -l';
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
    87
        outStream:outStream;
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
    88
        execute.
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
    89
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    90
    outStream contents inspect.
22197
444d71c29720 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22181
diff changeset
    91
                                                            [exEnd]
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
    92
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    93
  feed it from a smalltalk stream, get command's output into a Smalltalk stream:
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    94
                                                            [exBegin]
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    95
    |inStream outStream|
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    96
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    97
    inStream := 'hello world' readStream.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    98
    outStream := '' writeStream.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
    99
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   100
    OSProcess new 
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   101
        command:'tr ''a-z'' ''A-Z''';
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   102
        inStream:inStream;
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   103
        outStream:outStream;
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   104
        execute.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   105
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   106
    outStream contents inspect.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   107
                                                            [exEnd]
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   108
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   109
  again, send output to a Smalltalk stream;
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   110
  watch the stream getting filled after 10 seconds:
22197
444d71c29720 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22181
diff changeset
   111
                                                            [exBegin]
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   112
    |outStream|
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   113
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   114
    outStream := '' writeStream.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   115
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   116
    OSProcess new 
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   117
        command:'ls -l; sleep 10; echo =================================; echo hallo after 10s; echo >&2 +++++++++++++++++++++; cat >&2';
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   118
        outStream:outStream;
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   119
        errorStream:outStream;
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   120
        startProcess.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   121
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   122
    outStream inspect
22197
444d71c29720 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22181
diff changeset
   123
                                                            [exEnd]
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   124
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   125
  separate stdout and stderr:
22197
444d71c29720 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22181
diff changeset
   126
                                                            [exBegin]
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   127
    |outStream errStream|
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   128
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   129
    outStream := '' writeStream.
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   130
    errStream := '' writeStream.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   131
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   132
    OSProcess new 
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   133
        command:'ls -l && ls >&2';
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   134
        outStream:outStream;
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   135
        errorStream:errStream;
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   136
        startProcess.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   137
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   138
    outStream inspect.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   139
    errStream inspect.
22197
444d71c29720 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22181
diff changeset
   140
                                                            [exEnd]
21512
a78759923d34 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21332
diff changeset
   141
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   142
  Execute commands in shell/cmd.exe and read them from stdin:
22197
444d71c29720 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22181
diff changeset
   143
                                                            [exBegin]
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   144
    |outStream|
21512
a78759923d34 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21332
diff changeset
   145
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   146
    outStream := '' writeStream.
21512
a78759923d34 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21332
diff changeset
   147
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   148
    OSProcess new 
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   149
        command:'';
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   150
        inStream:'ls -l' readStream;
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   151
        outStream:outStream;
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   152
        lineWise:true;
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   153
        execute.
21512
a78759923d34 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21332
diff changeset
   154
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   155
    outStream contents inspect
22197
444d71c29720 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22181
diff changeset
   156
                                                            [exEnd]
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   157
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   158
  Execute on a remote host (you must have the appropriate ssh setup):
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   159
                                                            [exBegin]
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   160
    |outStream|
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   161
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   162
    outStream := '' writeStream.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   163
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   164
    (OSProcess onHost:'exeptn') 
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   165
        command:'ls -l';
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   166
        outStream:outStream;
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   167
        lineWise:true;
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   168
        execute.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   169
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   170
    outStream contents inspect
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   171
                                                            [exEnd]
21512
a78759923d34 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21332
diff changeset
   172
"
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   173
! !
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   174
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   175
!OSProcess class methodsFor:'instance creation'!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   176
22437
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   177
command:aCommandString
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   178
    "return an initialized instance to execute aCommandString
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   179
     in the current directory (for a local process)"
22437
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   180
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   181
    ^ self new command:aCommandString.
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   182
!
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   183
22438
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   184
command:aCommandString directory:aStringOrFilename
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   185
    "return an initialized instance to execute aCommandString 
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   186
     in a given directory (for a local process)"
22437
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   187
22438
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   188
    ^ self new command:aCommandString directory:aStringOrFilename.
22437
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   189
!
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   190
22568
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   191
commandStringForProgramName:executableFile arguments:arrayOfStrings
23184
5527a9f0dfd4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23183
diff changeset
   192
    "generate a command line string from appending args (possibley quoted) to the exe-name (with spaces)"
5527a9f0dfd4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23183
diff changeset
   193
22568
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   194
    ^ String streamContents:[:s |
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   195
        s nextPutAll:(self possiblyQuoted:executableFile asFilename pathName).
23182
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   196
        arrayOfStrings notNil ifTrue:[
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   197
            arrayOfStrings do:[:eachArg |
23183
76333ab19e6f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23182
diff changeset
   198
                s space.
23182
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   199
                s nextPutAll:(self possiblyQuoted:eachArg).
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   200
            ].
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   201
        ]
22568
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   202
    ]
23182
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   203
23184
5527a9f0dfd4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23183
diff changeset
   204
    "Modified (comment): / 02-07-2018 / 20:50:29 / cg"
22568
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   205
!
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   206
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   207
new
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   208
    "return an initialized instance for a local process"
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   209
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   210
    ^ self basicNew initialize.
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   211
!
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   212
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   213
onHost:aHost
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   214
    "return an initialized instance for a remote process running on another host"
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   215
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   216
    (SocketAddress hostName:aHost) isLocal ifTrue:[
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   217
        ^ self basicNew initialize.
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   218
    ].
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   219
    ^ RemoteOSProcess basicNew host:aHost; initialize.
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   220
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   221
    "
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   222
     OSProcess onHost:'localhost'
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   223
     OSProcess onHost:'exeptn'
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   224
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   225
     (OSProcess new) command:'ls'
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   226
     (OSProcess onHost:'exeptn') command:'ls'
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   227
    "
22568
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   228
!
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   229
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   230
possiblyQuoted:aString
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   231
    "should we quote or escape?"
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   232
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   233
    ^ String streamContents:[:s |
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   234
        aString do:[:ch |
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   235
            (ch isSeparator or:[ch = $\]) ifTrue:[
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   236
                s nextPut:$\
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   237
            ].
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   238
            s nextPut:ch
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   239
        ]
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   240
    ]
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   241
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   242
    "
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   243
     self possiblyQuoted:'foo bar' 
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   244
     self possiblyQuoted:'foo\bar'
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   245
    "
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   246
!
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   247
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   248
programName:executableFile arguments:arrayOfStrings initialEnvironment:stringDictionary
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   249
    "similar to command:, but with separate command and arguments"
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   250
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   251
    ^ self new
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   252
        command:(self commandStringForProgramName:executableFile arguments:arrayOfStrings);
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   253
        environment:stringDictionary;
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   254
        yourself
23182
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   255
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   256
    "
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   257
     (self programName:'notepad.exe' arguments:#() initialEnvironment:nil)
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   258
        showWindow:true;
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   259
        startProcess
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   260
    "
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   261
6082d007b7c3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23126
diff changeset
   262
    "Modified (comment): / 02-07-2018 / 20:33:02 / cg"
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   263
! !
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   264
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   265
!OSProcess class methodsFor:'class initialization'!
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   266
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   267
initialize
22568
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   268
    "Backward compatibility: Win32Process is an alias for OSProcess"
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   269
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   270
    Win32Process := self.
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   271
! !
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   272
22568
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   273
!OSProcess class methodsFor:'queries'!
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   274
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   275
defaultShellPath
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   276
    OperatingSystem isUNIXlike ifTrue:[
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   277
        ^ OperatingSystem getEnvironment:'SHELL' 
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   278
    ].
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   279
    ^ 'cmd'
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   280
! !
eb116af8c3a2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22439
diff changeset
   281
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   282
!OSProcess methodsFor:'accessing'!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   283
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   284
auxStream
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   285
    ^ auxStream
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   286
!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   287
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   288
auxStream:something
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   289
    "set an auxiliary input stream that will be available to the command as
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   290
     file descriptor 3"
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   291
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   292
    auxStream := something.
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   293
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   294
    "Modified (comment): / 23-02-2017 / 10:56:57 / Maren"
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   295
!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   296
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   297
command
22438
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   298
    "the OS (shell-) command"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   299
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   300
    ^ command
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   301
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   302
    "Created: / 10.11.1998 / 21:27:07 / cg"
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   303
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   304
22437
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   305
command:aStringOrArray 
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   306
    "set the command to be executed.
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   307
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   308
     If aStringOrArray is a String, the commandString is passed to a shell for execution
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   309
     - see the description of 'sh -c' in your UNIX manual ('cmd.exe' in your Windows manual).
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   310
     With an empty command, the shell will read commands from the passed input stream.
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   311
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   312
     If aCommandString is an Array, the first element is the command to be executed,
22439
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   313
     and the other elements are the arguments to the command. 
2a098663db2f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22438
diff changeset
   314
     No shell is invoked in this case."
22437
2eab35976e5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22436
diff changeset
   315
    
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   316
    command := aStringOrArray.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   317
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   318
22436
be3edafe55cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22199
diff changeset
   319
command:commandStringArg directory:stringOrFilenameArg
22438
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   320
    "set the command to be executed and directory, where to execute.
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   321
     If aStringOrArray is a String, the commandString is passed to a shell for execution
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   322
     - see the description of 'sh -c' in your UNIX manual ('cmd.exe' in your Windows manual).
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   323
     If aCommandString is an Array, the first element is the command to be executed,
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   324
     and the other elements are the arguments to the command. No shell is invoked in this case."
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   325
22436
be3edafe55cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22199
diff changeset
   326
    command := commandStringArg.
be3edafe55cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22199
diff changeset
   327
    directory := stringOrFilenameArg.
be3edafe55cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22199
diff changeset
   328
!
be3edafe55cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22199
diff changeset
   329
22181
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   330
command:commandArg environment:environmentArg directory:directoryArg inStream:inStreamArg outStream:outStreamArg errorStream:errorStreamArg auxStream:auxStreamArg showWindow:showWindowArg lineWise:lineWiseArg 
22438
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   331
    "set the command to be executed & directory, where to execute.
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   332
     and input/output streams.
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   333
     See comments in individual setters for more info"
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   334
22181
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   335
    command := commandArg.
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   336
    environment := environmentArg.
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   337
    directory := directoryArg.
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   338
    inStream := inStreamArg.
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   339
    outStream := outStreamArg.
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   340
    errorStream := errorStreamArg.
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   341
    auxStream := auxStreamArg.
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   342
    showWindow := showWindowArg.
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   343
    lineWise := lineWiseArg.
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   344
!
fa3f71f80d13 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 22148
diff changeset
   345
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   346
directory
22438
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   347
    "the directory where executed"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   348
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   349
    ^ directory
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   350
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   351
    "Created: / 10.11.1998 / 21:21:52 / cg"
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   352
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   353
22436
be3edafe55cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22199
diff changeset
   354
directory:aStringOrFilename
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   355
    "set the directory that will be set as the current directory of the command to be executed"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   356
22436
be3edafe55cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22199
diff changeset
   357
    directory := aStringOrFilename.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   358
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   359
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   360
environment
22438
7f0d16f4a407 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22437
diff changeset
   361
    "the shell environment"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   362
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   363
    ^ environment
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   364
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   365
    "Created: / 10.11.1998 / 21:26:34 / cg"
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   366
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   367
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   368
environment:aDictionary
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   369
    "set the environment variables of the command to be executed"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   370
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   371
    environment := aDictionary.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   372
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   373
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   374
errorStream
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   375
    ^ errorStream
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   376
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   377
    "Created: / 10.11.1998 / 21:26:34 / cg"
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   378
!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   379
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   380
errorStream:aStream
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   381
    "set the stream where the stderr output of the command is directed to"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   382
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   383
    errorStream := aStream.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   384
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   385
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   386
exitStatus
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   387
    "answer the exit status of the command or nil, if the command has not yet been finished"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   388
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   389
    ^ exitStatus
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   390
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   391
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   392
exitStatus:something
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   393
    "set the value of the instance variable 'exitStatus' (automatically generated)"
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   394
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   395
    exitStatus := something.
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   396
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   397
    "Created: / 10.11.1998 / 21:24:55 / cg"
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   398
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   399
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   400
finishSema
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   401
    "wait on this semaphore if you want to wait until the OS process has finished.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   402
     There may be multiple waiters, so it is a good idea to do a #waitUncounted"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   403
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   404
    ^ finishSema
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   405
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   406
    "Modified (comment): / 23-02-2017 / 10:53:17 / Maren"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   407
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   408
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   409
inStream
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   410
    ^ inStream
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   411
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   412
    "Created: / 10.11.1998 / 21:26:34 / cg"
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   413
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   414
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   415
inStream:aStream
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   416
    "set the stream where the stdin input of the command is read from"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   417
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   418
    inStream := aStream.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   419
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   420
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   421
lineWise
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   422
    ^ lineWise
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   423
!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   424
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   425
lineWise:aBoolean
21209
e9395c842124 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21208
diff changeset
   426
    "When setting to true, read linewise from the command's output and error.
e9395c842124 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 21208
diff changeset
   427
     This is a bit slower than lineWise = false.
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   428
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   429
     You may use it also when streaming to e.g. Transcript"
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   430
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   431
    lineWise := aBoolean.
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   432
!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   433
21182
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   434
newPgrp
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   435
    ^ newPgrp
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   436
!
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   437
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   438
newPgrp:aBoolean
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   439
    "if aBoolean is true, a new process group will be created for the command and its subprocesses"
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   440
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   441
    newPgrp := aBoolean.
21182
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   442
!
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   443
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   444
outStream
22985
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   445
    "the stream where the stdout output of the command is directed to"
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   446
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   447
    ^ outStream
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   448
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   449
    "Created: / 10.11.1998 / 21:26:34 / cg"
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   450
!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   451
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   452
outStream:aStream
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   453
    "set the stream where the stdout output of the command is directed to"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   454
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   455
    outStream := aStream.
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   456
!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   457
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   458
pid
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   459
    "answer the pid of the process the command is running in or nil, if the command has not yet been started."
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   460
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   461
    ^ pid
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   462
!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   463
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   464
showWindow
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   465
    ^ showWindow
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   466
!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   467
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   468
showWindow:aBooleanOrNil
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   469
    "This parameter is ignored on Unix systems.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   470
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   471
     You can control (have to - sigh) if a window should be shown for the command or not.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   472
     This is the OS's H_SHOWWINDOW argument.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   473
     If you pass nil as showWindow-argument, the OS's default is used for the particular
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   474
     command, which is correct most of the time: i.e. a notepad will open its window, other (non-UI)
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   475
     executables will not.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   476
     However, some command-line executables show a window, even if they should not.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   477
     (and also, there seems to be an inconsistency between windows7 and newer windows: in newer,
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   478
     a shell command opens a cmd-window, whereas in windows7 it did not)
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   479
     In this case, pass an explicit false argument to suppress it."
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   480
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   481
    showWindow := aBooleanOrNil.
21206
aad552f2f306 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21205
diff changeset
   482
!
aad552f2f306 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21205
diff changeset
   483
aad552f2f306 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21205
diff changeset
   484
terminateActionBlock
22985
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   485
    "the (user provided) callback block,
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   486
     that will be executed when the command has finished or was terminated.
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   487
     If non-nil, it will be called with optional argument:status and:self, the OSProcess."
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   488
21206
aad552f2f306 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21205
diff changeset
   489
    ^ terminateActionBlock
22985
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   490
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   491
    "Modified (comment): / 22-05-2018 / 12:21:24 / Claus Gittinger"
21206
aad552f2f306 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21205
diff changeset
   492
!
aad552f2f306 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21205
diff changeset
   493
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   494
terminateActionBlock:aBlock
22985
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   495
    "set the callback block,
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   496
     that will be called when the command has finished or was terminated.
22986
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   497
     If non-nil, it will be called with optional argument:status and:self, the OSProcess.
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   498
     WARNING: 
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   499
        if the active-process calling #startProcess is already dead (i.e. terminated),
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   500
        this callback will be called by the scheduler;
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   501
        otherwise, the calling process will be interrupted to perform this callback.
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   502
        Therefore: do not open any GUI or other blocking actions in it."
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   503
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   504
    terminateActionBlock := aBlock.
22985
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   505
22986
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   506
    "Modified (comment): / 22-05-2018 / 12:42:21 / Claus Gittinger"
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   507
! !
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   508
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   509
!OSProcess methodsFor:'initialization'!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   510
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   511
initialize
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   512
    "Invoked when a new instance is created."
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   513
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   514
    showWindow := false.    "/ for backward compatibility
21183
fdeb19204fb2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21182
diff changeset
   515
    lineWise := false.
fdeb19204fb2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21182
diff changeset
   516
    newPgrp := true.
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   517
! !
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   518
23002
191ea99d1a08 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22994
diff changeset
   519
13313
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   520
!OSProcess methodsFor:'printing'!
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   521
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   522
printOn:aStream
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   523
    aStream 
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   524
        nextPutAll:self className;
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   525
        nextPut:$(.
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   526
    pid printOn:aStream.
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   527
    aStream space.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   528
    command printOn:aStream.
13313
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   529
    aStream nextPut:$)
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   530
! !
e5a29a7594be added: #printOn:
Stefan Vogel <sv@exept.de>
parents: 12890
diff changeset
   531
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   532
!OSProcess methodsFor:'private'!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   533
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   534
setupShufflerForInput:aStream
21182
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   535
    "if aStream is an internal Stream, set up a pipe for the command input.
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   536
     Start a process that shuffles the data from the internal stream into the pipe
21182
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   537
     (and into the command's input)."
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   538
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   539
    |pipe externalStream shuffledStream shufflerProcess|
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   540
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   541
    (aStream isNil or:[aStream isExternalStream]) ifTrue:[
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   542
        ^ aStream.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   543
    ].
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   544
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   545
    pipe := NonPositionableExternalStream makePipe.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   546
    externalStream := pipe at:1.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   547
    shuffledStream := pipe at:2.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   548
    lineWise ifFalse:[
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   549
        shuffledStream blocking:false.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   550
    ].
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   551
    aStream isBinary ifTrue:[
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   552
        shuffledStream binary.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   553
    ].
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   554
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   555
    "/ start a reader process, shuffling data from the given
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   556
    "/ inStream to the pipe (which is connected to the commands input)
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   557
    shufflerProcess := 
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   558
        [
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   559
            [
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   560
                lineWise ifTrue:[
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   561
                    "shuffle until end-of-input"
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   562
                    [aStream atEnd] whileFalse:[
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   563
                        |data|
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   564
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   565
                        data := aStream nextLine.
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   566
                        data notNil ifTrue:[
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   567
                            shuffledStream nextPutLine:data.
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   568
                            shuffledStream flush.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   569
                        ].
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   570
                    ].
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   571
                ] ifFalse:[
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   572
                    aStream copyToEndInto:shuffledStream.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   573
                ].
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   574
            ] on:WriteError do:[:ex|
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   575
                "ignore"
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   576
            ] ensure:[
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   577
                shuffledStream close.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   578
            ]
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   579
        ] newProcess
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   580
            name:'OSProcess input shuffler';
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   581
"/                beSystemProcess;
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   582
            resume.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   583
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   584
    shufflerProcesses add:shufflerProcess.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   585
    streamsToClose add:externalStream.
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   586
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   587
    ^ externalStream
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   588
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   589
    "Modified: / 31-01-2017 / 16:50:39 / stefan"
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   590
    "Modified (comment): / 23-02-2017 / 10:51:34 / Maren"
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   591
!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   592
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   593
setupShufflerForOutput:aStream
21182
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   594
    "if aStream is an internal Stream, set up a pipe for the command output.
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   595
     Start a process that shuffles the data fron the pipe into the internal stream."
001704ae8bbf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21181
diff changeset
   596
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   597
    |pipe externalStream shuffledStream shufflerProcess|
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   598
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   599
    (aStream isNil or:[aStream isExternalStream]) ifTrue:[
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   600
        ^ aStream.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   601
    ].
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   602
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   603
    pipe := NonPositionableExternalStream makePipe.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   604
    externalStream := pipe at:2.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   605
    shuffledStream := pipe at:1.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   606
    aStream isBinary ifTrue:[
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   607
        shuffledStream binary.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   608
    ].
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   609
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   610
    shufflerProcess := 
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   611
        [
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   612
            [
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   613
                "shuffle until the pipe closes"
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   614
                lineWise ifTrue:[
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   615
                    [shuffledStream atEnd] whileFalse:[
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   616
                        |data|
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   617
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   618
                        data := shuffledStream nextLine.
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   619
                        data notNil ifTrue:[
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   620
                            aStream nextPutLine:data
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   621
                        ].
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   622
                    ].
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   623
                ] ifFalse:[
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   624
                    shuffledStream copyToEndInto:aStream.
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   625
                ].
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   626
            ] on:WriteError do:[:ex |
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   627
                "ignore" 
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   628
            ] ensure:[
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   629
                shuffledStream close.
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   630
            ].
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   631
        ] newProcess
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   632
            priority:(Processor userSchedulingPriority "+ 1");
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   633
            name:'OSProcess output shuffler';
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   634
"/                beSystemProcess;
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   635
            resume.
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   636
21223
bebca95ca864 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21209
diff changeset
   637
    shufflerProcesses add:shufflerProcess.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   638
    streamsToClose add:externalStream.
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   639
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   640
    ^ externalStream
21332
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   641
18ca24f32565 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21226
diff changeset
   642
    "Modified: / 31-01-2017 / 16:57:25 / stefan"
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   643
!
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   644
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   645
startCommand
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   646
    "the 'real' command to be executed.
22987
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   647
     Redefined for remote processes (eg. to construct a remote command string).
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   648
     Command may be both an Array or a String"
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   649
    
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   650
    ^ command
22987
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   651
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   652
    "Modified (comment): / 22-05-2018 / 12:37:38 / Stefan Vogel"
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   653
! !
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   654
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   655
!OSProcess methodsFor:'queries'!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   656
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   657
finishedWithSuccess
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   658
    ^ exitStatus notNil and:[exitStatus success].
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   659
!
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   660
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   661
isAlive
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   662
    "answer true if the process is still alive"
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   663
21205
580c1baf6e3f #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21200
diff changeset
   664
    ^ pid notNil and:[exitStatus isNil]
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   665
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   666
    "Modified (comment): / 23-02-2017 / 10:52:37 / Maren"
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   667
!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   668
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   669
isDead
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   670
    "answer true if the process is no longer alive"
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   671
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   672
    ^ self isAlive not
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   673
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   674
    "Modified (comment): / 23-02-2017 / 10:52:31 / Maren"
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   675
! !
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   676
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   677
!OSProcess methodsFor:'starting'!
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   678
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   679
execute
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   680
    "execute the command. 
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   681
     Wait until it is finished.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   682
     Abort the execution if I am interrupted.
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   683
     Answer true if it terminated successfully, 
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   684
     false if it could not be started or terminated with error."
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   685
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   686
    |ok|
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   687
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   688
    [
21185
b2ecc061106c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21184
diff changeset
   689
        ok := self startProcess.
b2ecc061106c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21184
diff changeset
   690
        ok ifTrue:[
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   691
            self waitUntilFinished.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   692
            ok := self finishedWithSuccess.
21185
b2ecc061106c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21184
diff changeset
   693
        ].
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   694
    ] ifCurtailed:[
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   695
        "/ we were interrupted -
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   696
        "/ terminate the os-command (and all of its forked commands)
21185
b2ecc061106c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21184
diff changeset
   697
        pid notNil ifTrue:[
b2ecc061106c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21184
diff changeset
   698
            self terminateGroup.
b2ecc061106c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21184
diff changeset
   699
        ].
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   700
    ].
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   701
    ^ ok.
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   702
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   703
    "Modified (comment): / 23-02-2017 / 10:54:34 / Maren"
21181
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   704
!
a8a9220ed86f #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21172
diff changeset
   705
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   706
startProcess
22987
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   707
    "Start the command asynchronously (i.e. don't wait until is has finished).
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   708
     If there are non-external streams, setup transfer (shuffler) processes
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   709
     to transfer data from a pipe to the internal stream.
22987
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   710
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   711
     Answer true if the command could started succesfully, false if not.
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   712
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   713
     NOTE: under normal circumstances, even if the command cannot be found,
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   714
           the exit fom the command interpreter/shell is done some time later
3ee91cc9e2d0 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 22986
diff changeset
   715
           So you have to check later or set #terminateActionBlock: and check there."
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   716
22986
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   717
    |externalInStream externalAuxStream externalErrorStream externalOutStream callingProcess|
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   718
21200
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   719
    shufflerProcesses := OrderedCollection new:4.
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   720
    streamsToClose := OrderedCollection new:2.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   721
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   722
    externalInStream := self setupShufflerForInput:inStream.
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   723
    externalAuxStream := self setupShufflerForInput:auxStream.
21226
568b192939c7 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21223
diff changeset
   724
    externalOutStream := self setupShufflerForOutput:outStream.
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   725
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   726
    errorStream == outStream ifTrue:[
21226
568b192939c7 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21223
diff changeset
   727
        externalErrorStream := externalOutStream.
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   728
    ] ifFalse:[
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   729
        externalErrorStream := self setupShufflerForOutput:errorStream.
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   730
    ].
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   731
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   732
    "start the command"
21200
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   733
    finishSema := EventSemaphore new.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   734
22983
954925788d5d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22568
diff changeset
   735
    "/ UserPreferences current logExecutedOSCommands:true
954925788d5d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22568
diff changeset
   736
    UserPreferences current logExecutedOSCommands ifTrue:[
23002
191ea99d1a08 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22994
diff changeset
   737
        Transcript showCR:(('OS command: ', self startCommand printString) withColor:Color brown).  
22983
954925788d5d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22568
diff changeset
   738
    ].
22986
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   739
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   740
    callingProcess := Processor activeProcess.
22983
954925788d5d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22568
diff changeset
   741
    
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   742
    Processor 
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   743
        monitor:[
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   744
            pid := OperatingSystem
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   745
                        startProcess:(self startCommand)
21200
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   746
                        inputFrom:externalInStream
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   747
                        outputTo:externalOutStream
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   748
                        errorTo:externalErrorStream
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   749
                        auxFrom:externalAuxStream
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   750
                        environment:environment
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   751
                        inDirectory:directory
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   752
                        newPgrp:newPgrp
6de129aead00 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21185
diff changeset
   753
                        showWindow:showWindow.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   754
        ] 
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   755
        action:[:status |
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   756
            status stillAlive ifFalse:[
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   757
                exitStatus := status.
23006
0427d51adb60 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23002
diff changeset
   758
                self terminate.
0427d51adb60 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23002
diff changeset
   759
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   760
                "/ shufflerProcesses do:[:eachProcess|
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   761
                "/     "terminate the shuffler processes.
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   762
                "/      They close the local side of the pipe when being terminated"
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   763
                "/    eachProcess terminate.
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   764
                "/ ].
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   765
                
21223
bebca95ca864 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21209
diff changeset
   766
                finishSema signal.
22985
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   767
                terminateActionBlock notNil ifTrue:[
22986
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   768
                    callingProcess isDead ifTrue:[    
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   769
                        terminateActionBlock valueWithOptionalArgument:status and:self.
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   770
                    ] ifFalse:[
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   771
                        callingProcess 
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   772
                            interruptWith:[
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   773
                                terminateActionBlock valueWithOptionalArgument:status and:self.
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   774
                            ]        
6574facad5bf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22985
diff changeset
   775
                    ].    
22985
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   776
                ].
23126
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   777
                UserPreferences current logExecutedOSCommands ifTrue:[
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   778
                    Transcript 
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   779
                        showCR:(('OS command finished: %1 status: %2'
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   780
                                    bindWith: self startCommand
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   781
                                    with:status code)     
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   782
                                    withColor:(
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   783
                                        status success 
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   784
                                            ifTrue:[Color green darkened]
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   785
                                            ifFalse:[Color red])).  
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   786
                ].
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   787
            ].
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   788
        ].
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   789
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   790
    "we can close the remote side of the pipes after the os process has been started (after the fork)"
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   791
    streamsToClose do:[:eachStream | eachStream close].
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   792
    streamsToClose := nil.
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   793
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   794
    pid isNil ifTrue:[
23126
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   795
        UserPreferences current logExecutedOSCommands ifTrue:[
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   796
            Transcript 
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   797
                showCR:(('OS command failed: %1'
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   798
                            bindWith: self startCommand)     
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   799
                            withColor:(Color red)).  
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   800
        ].
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   801
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   802
        "process could not be started - terminate shufflers"
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   803
        shufflerProcesses do:[:eachProcess|
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   804
            eachProcess terminate.
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   805
        ].
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   806
        shufflerProcesses := nil.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   807
        exitStatus := OperatingSystem osProcessStatusClass processCreationFailure.
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   808
        finishSema signal.
23006
0427d51adb60 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23002
diff changeset
   809
        terminateActionBlock notNil ifTrue:[
0427d51adb60 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23002
diff changeset
   810
            terminateActionBlock valueWithOptionalArgument:exitStatus and:self.
0427d51adb60 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23002
diff changeset
   811
        ].
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   812
        ^ false.
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   813
    ].
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   814
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   815
    ^ true.
22985
da550df21477 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22984
diff changeset
   816
23006
0427d51adb60 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 23002
diff changeset
   817
    "Modified: / 24-05-2018 / 17:58:40 / Stefan Vogel"
23126
afbeb2bb7afc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23035
diff changeset
   818
    "Modified: / 21-06-2018 / 19:01:38 / Claus Gittinger"
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   819
! !
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   820
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   821
!OSProcess methodsFor:'terminating'!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   822
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   823
kill
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   824
    "kill the process - the process does not get the chance to clean up"
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   825
    
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   826
    pid notNil ifTrue:[
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   827
        OperatingSystem killProcess:pid.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   828
    ].
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   829
!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   830
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   831
killGroup
20379
135c4fc19014 #OTHER by mawalch
mawalch
parents: 19298
diff changeset
   832
    "kill the processGroup - the processes do not get the chance to clean up"
135c4fc19014 #OTHER by mawalch
mawalch
parents: 19298
diff changeset
   833
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   834
    pid notNil ifTrue:[
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   835
        OperatingSystem 
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   836
            killProcessGroup:pid;
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   837
            killProcess:pid.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   838
    ].
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   839
!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   840
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   841
terminate
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   842
    "terminate the process gracefully"
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   843
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   844
    pid notNil ifTrue:[
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   845
        OperatingSystem terminateProcess:pid.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   846
    ].
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   847
!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   848
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   849
terminateGroup
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   850
    "terminate the process group.
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   851
     Under Windows, this is the same as terminateWithAllChildren,
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   852
     under unix, this terminates a subset of all children"
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   853
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   854
    pid notNil ifTrue:[
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   855
        OperatingSystem 
21632
747d14b5ff37 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21552
diff changeset
   856
            terminateProcess:pid;
747d14b5ff37 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21552
diff changeset
   857
            terminateProcessGroup:pid.
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   858
    ].
21551
a00b3ea45664 #DOCUMENTATION by Maren
matilk
parents: 21512
diff changeset
   859
21552
7732a5719d14 #DOCUMENTATION by Maren
matilk
parents: 21551
diff changeset
   860
    "Modified (comment): / 23-02-2017 / 10:50:13 / Maren"
21632
747d14b5ff37 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21552
diff changeset
   861
    "Modified: / 09-03-2017 / 15:00:58 / stefan"
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   862
! !
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   863
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   864
!OSProcess methodsFor:'waiting'!
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   865
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   866
waitUntilFinished
23035
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
   867
    <resource: #skipInDebuggersWalkBack>
22148
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   868
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   869
    "wait with a veryy long timeout, 
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   870
     in order that ProcessorScheduler>>#checkForEndOfDispatch recogizes
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   871
     this waiting process as user process which is still alive.
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   872
     The timout is meant to never occur!!"
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   873
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   874
    ^ self waitUntilFinishedWithTimeout:60*60*24000
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   875
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   876
    "Modified: / 01-08-2017 / 14:41:10 / stefan"
9f3d3f09551d #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21632
diff changeset
   877
    "Modified (comment): / 01-08-2017 / 17:15:55 / stefan"
23035
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
   878
    "Modified: / 30-05-2018 / 13:57:42 / Claus Gittinger"
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   879
!
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   880
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   881
waitUntilFinishedWithTimeout:timeout
23035
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
   882
    <resource: #skipInDebuggersWalkBack>
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
   883
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   884
    |processList|
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   885
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   886
    (finishSema waitWithTimeout:timeout) isNil ifTrue:[
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   887
        "timed out"
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   888
        ^ nil.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   889
    ].
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   890
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   891
    "have to wait until the shufflers have finished their work"
21208
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   892
    processList := shufflerProcesses.
9fbb51649256 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21206
diff changeset
   893
    processList notEmptyOrNil ifTrue:[
21184
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   894
        processList do:[:eachProcess | 
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   895
            eachProcess waitUntilTerminated.
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   896
        ].
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   897
        shufflerProcesses := nil.
190ae0ab71c2 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 21183
diff changeset
   898
    ].
23035
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
   899
98ae4fba66a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 23006
diff changeset
   900
    "Modified: / 30-05-2018 / 13:57:39 / Claus Gittinger"
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   901
! !
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   902
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   903
!OSProcess::RemoteOSProcess class methodsFor:'documentation'!
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   904
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   905
documentation
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   906
"
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   907
    Instances of OSProcess represent operating system processes that can be executed.
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   908
    (as opposed to Smalltalk processes).
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   909
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   910
    [author:]
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   911
        cg
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   912
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   913
    [instance variables:]
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   914
        host        String          the host on which to execute the command
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   915
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   916
    [class variables:]
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   917
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   918
    [see also:]
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   919
        Process
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   920
"
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   921
!
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   922
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   923
examples
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   924
"
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   925
                                                            [exBegin]
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   926
    |outStream|
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   927
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   928
    outStream := '' writeStream.
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   929
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   930
    (OSProcess onHost:'exeptn') 
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   931
        command:'ls -l';
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   932
        inStream:'abc' readStream;
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   933
        outStream:outStream;
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   934
        lineWise:true;
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   935
        execute.
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   936
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   937
    outStream contents
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   938
                                                            [exEnd]
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   939
"
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   940
! !
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   941
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   942
!OSProcess::RemoteOSProcess methodsFor:'accessing'!
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   943
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   944
host
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   945
    ^ host
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   946
!
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   947
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   948
host:aHostName
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   949
    host := aHostName.
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   950
! !
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   951
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   952
!OSProcess::RemoteOSProcess methodsFor:'private'!
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   953
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   954
startCommand
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   955
    "the 'real' command"
22199
4638d345471d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22198
diff changeset
   956
4638d345471d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22198
diff changeset
   957
    "for now, always use ssh; 
4638d345471d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22198
diff changeset
   958
     later, this should be configurable, 
4638d345471d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22198
diff changeset
   959
     which remote mechanism is to be used per host"
4638d345471d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22198
diff changeset
   960
     
22198
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   961
    ^ 'ssh %1 "%2"' bindWith:host with:command
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   962
! !
c81fce52627d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22197
diff changeset
   963
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   964
!OSProcess class methodsFor:'documentation'!
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   965
19298
cfacc6b159c5 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19286
diff changeset
   966
version
cfacc6b159c5 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19286
diff changeset
   967
    ^ '$Header$'
cfacc6b159c5 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19286
diff changeset
   968
!
cfacc6b159c5 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19286
diff changeset
   969
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   970
version_CVS
19286
9e8eea97fd57 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 13313
diff changeset
   971
    ^ '$Header$'
12890
2488b1f65af2 initial checkin
Stefan Vogel <sv@exept.de>
parents:
diff changeset
   972
! !
19286
9e8eea97fd57 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 13313
diff changeset
   973
21172
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   974
36a0e5430705 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 20379
diff changeset
   975
OSProcess initialize!