5
<a href ="NSString.html">[Previous] </a>
6
<a href ="Base.html">[Up] </a>
7
<a href ="NSThread.html">[Next] </a>
11
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
14
<p>Version: $Revision: 1.14 $</p>
15
<p>Date: $Date: 2001/12/12 14:10:13 $</p>
16
<h2><a name ="cont-0">NSTask</a></h2>
17
<h2><a name ="NSTask">NSTask</a></h2>
18
<p><b>Declared in: </b> Foundation/NSTask.h</p>
19
<p><b>Inherits from: </b> NSObject</p>
20
<p><b>Conforms to: </b> NSObject
24
The NSTask class provides a mechanism to run separate tasks
25
under (limited) control of your program.
27
<h2>Instance Variables </h2>
32
<li ><a href ="NSTask.html#method-0">+launchedTaskWithLaunchPath:arguments:</a>
33
<li ><a href ="NSTask.html#method-1">-arguments</a>
34
<li ><a href ="NSTask.html#method-2">-currentDirectoryPath</a>
35
<li ><a href ="NSTask.html#method-3">-environment</a>
36
<li ><a href ="NSTask.html#method-4">-interrupt</a>
37
<li ><a href ="NSTask.html#method-5">-isRunning</a>
38
<li ><a href ="NSTask.html#method-6">-launch</a>
39
<li ><a href ="NSTask.html#method-7">-launchPath</a>
40
<li ><a href ="NSTask.html#method-8">-processIdentifer</a>
41
<li ><a href ="NSTask.html#method-19">-resume</a>
42
<li ><a href ="NSTask.html#method-9">-setArguments:</a>
43
<li ><a href ="NSTask.html#method-10">-setCurrentDirectoryPath:</a>
44
<li ><a href ="NSTask.html#method-11">-setEnvironment:</a>
45
<li ><a href ="NSTask.html#method-12">-setLaunchPath:</a>
46
<li ><a href ="NSTask.html#method-13">-setStandardError:</a>
47
<li ><a href ="NSTask.html#method-14">-setStandardInput:</a>
48
<li ><a href ="NSTask.html#method-15">-setStandardOutput:</a>
49
<li ><a href ="NSTask.html#method-16">-standardError</a>
50
<li ><a href ="NSTask.html#method-17">-standardInput</a>
51
<li ><a href ="NSTask.html#method-18">-standardOutput</a>
52
<li ><a href ="NSTask.html#method-20">-suspend</a>
53
<li ><a href ="NSTask.html#method-21">-terminate</a>
54
<li ><a href ="NSTask.html#method-22">-terminationStatus</a>
55
<li ><a href ="NSTask.html#method-23">-usePseudoTerminal</a>
56
<li ><a href ="NSTask.html#method-24">-waitUntilExit</a>
58
<hr><h2>Class Methods </h2>
59
<h3><a name ="method-0">launchedTaskWithLaunchPath:arguments:</a></h3>
60
+ (NSTask*) <b>launchedTaskWithLaunchPath:</b> (NSString*)path <b>arguments:</b> (NSArray*)arguments;<br>
62
Creates and launches a task, returning an autoreleased task object.
63
Supplies the path to the executable and an array of argument.
64
The task inherits the parents environment and I/O.
67
<hr><h2>Instances Methods </h2>
68
<h3><a name ="method-1">arguments</a></h3>
69
- (NSArray*) <b>arguments</b>;<br>
71
Returns the arguments set for the task.
74
<h3><a name ="method-2">currentDirectoryPath</a></h3>
75
- (NSString*) <b>currentDirectoryPath</b>;<br>
77
Returns the working directory set for the task.
80
<h3><a name ="method-3">environment</a></h3>
81
- (NSDictionary*) <b>environment</b>;<br>
83
Returns the environment set for the task.
86
<h3><a name ="method-4">interrupt</a></h3>
87
- (void) <b>interrupt</b>;<br>
89
Sends an interrupt signal to the receiver and any subtasks.<br>
90
If the task has not been launched, raises an
91
NSInvalidArgumentException.<br>
92
Has no effect on a task that has already terminated.<br>
93
This is rather like the terminate method, but the child
94
process may not choose to terminate in response to an interrupt.
97
<h3><a name ="method-5">isRunning</a></h3>
98
- (BOOL) <b>isRunning</b>;<br>
100
Checks to see if the task is currently running.
103
<h3><a name ="method-6">launch</a></h3>
104
- (void) <b>launch</b>;<br>
106
Launches the task.<br>
107
Raises an NSInvalidArgumentException if the launch path is not
108
set or if the subtask cannot be started for some reason
109
(eg. the executable does not exist).
112
<h3><a name ="method-7">launchPath</a></h3>
113
- (NSString*) <b>launchPath</b>;<br>
115
Returns the launch path set for the task.
118
<h3><a name ="method-8">processIdentifer</a></h3>
119
- (int) <b>processIdentifer</b>;<br>
121
Returns the number identifying the child process on this system.
124
<h3><a name ="method-9">setArguments:</a></h3>
125
- (void) <b>setArguments:</b> (NSArray*)arguments;<br>
127
Sets an array of arguments to be supplied to the task when it
128
is launched. The default is an empty array. This method cannot
129
be used after a task is launched ...
130
it raises an NSInvalidArgumentException.
133
<h3><a name ="method-10">setCurrentDirectoryPath:</a></h3>
134
- (void) <b>setCurrentDirectoryPath:</b> (NSString*)path;<br>
136
Sets the home directory in which the task is to be run.
137
The default is the parent processes directory.
138
This method cannot be used after a task is launched ...
139
it raises an NSInvalidArgumentException.
142
<h3><a name ="method-11">setEnvironment:</a></h3>
143
- (void) <b>setEnvironment:</b> (NSDictionary*)environmentDictionary;<br>
145
Sets the environment variables for the task to be run.
146
The default is the parent processes environment.
147
This method cannot be used after a task is launched ...
148
it raises an NSInvalidArgumentException.
151
<h3><a name ="method-12">setLaunchPath:</a></h3>
152
- (void) <b>setLaunchPath:</b> (NSString*)path;<br>
154
Sets the path to the executable file to be run.
155
There is no default for this - you must set the launch path.
156
This method cannot be used after a task is launched ...
157
it raises an NSInvalidArgumentException.
160
<h3><a name ="method-13">setStandardError:</a></h3>
161
- (void) <b>setStandardError:</b> (id)file;<br>
163
Sets the standard error stream for the task.<br>
164
This is normally a writable NSFileHandle object.
165
If this is an NSPipe, the write end of the pipe is
166
automatically closed on launching.<br>
167
The default behavior is to inherit the parent processes
169
This method cannot be used after a task is launched ...
170
it raises an NSInvalidArgumentException.
173
<h3><a name ="method-14">setStandardInput:</a></h3>
174
- (void) <b>setStandardInput:</b> (id)file;<br>
176
Sets the standard input stream for the task.<br>
177
This is normally a readable NSFileHandle object.
178
If this is an NSPipe, the read end of the pipe is
179
automatically closed on launching.<br>
180
The default behavior is to inherit the parent processes
182
This method cannot be used after a task is launched ...
183
it raises an NSInvalidArgumentException.
186
<h3><a name ="method-15">setStandardOutput:</a></h3>
187
- (void) <b>setStandardOutput:</b> (id)file;<br>
189
Sets the standard output stream for the task.<br>
190
This is normally a writable NSFileHandle object.
191
If this is an NSPipe, the write end of the pipe is
192
automatically closed on launching.<br>
193
The default behavior is to inherit the parent processes
195
This method cannot be used after a task is launched ...
196
it raises an NSInvalidArgumentException.
199
<h3><a name ="method-16">standardError</a></h3>
200
- (id) <b>standardError</b>;<br>
202
Returns the standard error stream for the task - an NSFileHandle
203
unless an NSPipe was passed to setStandardError:
206
<h3><a name ="method-17">standardInput</a></h3>
207
- (id) <b>standardInput</b>;<br>
209
Returns the standard input stream for the task - an NSFileHandle
210
unless an NSPipe was passed to setStandardInput:
213
<h3><a name ="method-18">standardOutput</a></h3>
214
- (id) <b>standardOutput</b>;<br>
216
Returns the standard output stream for the task - an NSFileHandle
217
unless an NSPipe was passed to setStandardOutput:
220
<h3><a name ="method-19">resume</a></h3>
221
- (BOOL) <b>resume</b>;<br>
223
Sends a cont signal to the receiver and any subtasks.<br>
224
If the task has not been launched, raises an
225
NSInvalidArgumentException.<br>
228
<h3><a name ="method-20">suspend</a></h3>
229
- (BOOL) <b>suspend</b>;<br>
231
Sends a stop signal to the receiver and any subtasks.<br>
232
If the task has not been launched, raises an
233
NSInvalidArgumentException.<br>
236
<h3><a name ="method-21">terminate</a></h3>
237
- (void) <b>terminate</b>;<br>
239
Sends a terminate signal to the receiver and any subtasks.<br>
240
If the task has not been launched, raises an
241
NSInvalidArgumentException.<br>
242
Has no effect on a task that has already terminated.<br>
243
When a task temrinates, either due to this method being called,
244
or normal termination, an NSTaskDidTerminateNotification is
248
<h3><a name ="method-22">terminationStatus</a></h3>
249
- (int) <b>terminationStatus</b>;<br>
251
Returns the termination status of the task.<br>
252
If the task has not completed running, raises an
253
NSInvalidArgumentException.
256
<h3><a name ="method-23">usePseudoTerminal</a></h3>
257
- (BOOL) <b>usePseudoTerminal</b>;<br>
258
Standards: GNUstep NotMacOS-X NotOpenStep<br>
260
If the system supports it, this method sets the standard
261
input, output, and error streams to a pseudo-terminal so
262
that, when launched, the child task will act as if it was
263
running interactively on a terminal. The file handles
264
can then be used to communicate with the child.<br>
265
This method cannot be used after a task is launched ...
266
it raises an NSInvalidArgumentException.<br>
267
The standard input, output and error streams cannot be
268
changed after calling this method.<br>
269
The method returns YES on success, NO on failure.
272
<h3><a name ="method-24">waitUntilExit</a></h3>
273
- (void) <b>waitUntilExit</b>;<br>
275
Suspends the current thread until the task terminates, by
276
waiting in NSRunLoop (NSDefaultRunLoopMode) for the task
278
Returns immediately if the task is not running.