mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-28 19:20:51 +00:00
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10501 72102866-910b-0410-8b05-ffd578937521
283 lines
10 KiB
HTML
283 lines
10 KiB
HTML
<html><head>
|
|
<title>NSTask</title>
|
|
</head>
|
|
<body>
|
|
<a href ="NSString.html">[Previous] </a>
|
|
<a href ="Base.html">[Up] </a>
|
|
<a href ="NSThread.html">[Next] </a>
|
|
<h1>NSTask</h1>
|
|
<h3>Authors </h3>
|
|
<dl>
|
|
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
|
|
<dd>
|
|
</dl>
|
|
<p>Version: $Revision$</p>
|
|
<p>Date: $Date$</p>
|
|
<h2><a name ="cont-0">NSTask</a></h2>
|
|
<h2><a name ="NSTask">NSTask</a></h2>
|
|
<p><b>Declared in: </b> Foundation/NSTask.h</p>
|
|
<p><b>Inherits from: </b> NSObject</p>
|
|
<p><b>Conforms to: </b> NSObject
|
|
</p>
|
|
<hr>
|
|
|
|
The NSTask class provides a mechanism to run separate tasks
|
|
under (limited) control of your program.
|
|
|
|
<h2>Instance Variables </h2>
|
|
<ul>
|
|
</ul>
|
|
<h2>Methods </h2>
|
|
<ul>
|
|
<li ><a href ="NSTask.html#method-0">+launchedTaskWithLaunchPath:arguments:</a>
|
|
<li ><a href ="NSTask.html#method-1">-arguments</a>
|
|
<li ><a href ="NSTask.html#method-2">-currentDirectoryPath</a>
|
|
<li ><a href ="NSTask.html#method-3">-environment</a>
|
|
<li ><a href ="NSTask.html#method-4">-interrupt</a>
|
|
<li ><a href ="NSTask.html#method-5">-isRunning</a>
|
|
<li ><a href ="NSTask.html#method-6">-launch</a>
|
|
<li ><a href ="NSTask.html#method-7">-launchPath</a>
|
|
<li ><a href ="NSTask.html#method-8">-processIdentifer</a>
|
|
<li ><a href ="NSTask.html#method-19">-resume</a>
|
|
<li ><a href ="NSTask.html#method-9">-setArguments:</a>
|
|
<li ><a href ="NSTask.html#method-10">-setCurrentDirectoryPath:</a>
|
|
<li ><a href ="NSTask.html#method-11">-setEnvironment:</a>
|
|
<li ><a href ="NSTask.html#method-12">-setLaunchPath:</a>
|
|
<li ><a href ="NSTask.html#method-13">-setStandardError:</a>
|
|
<li ><a href ="NSTask.html#method-14">-setStandardInput:</a>
|
|
<li ><a href ="NSTask.html#method-15">-setStandardOutput:</a>
|
|
<li ><a href ="NSTask.html#method-16">-standardError</a>
|
|
<li ><a href ="NSTask.html#method-17">-standardInput</a>
|
|
<li ><a href ="NSTask.html#method-18">-standardOutput</a>
|
|
<li ><a href ="NSTask.html#method-20">-suspend</a>
|
|
<li ><a href ="NSTask.html#method-21">-terminate</a>
|
|
<li ><a href ="NSTask.html#method-22">-terminationStatus</a>
|
|
<li ><a href ="NSTask.html#method-23">-usePseudoTerminal</a>
|
|
<li ><a href ="NSTask.html#method-24">-waitUntilExit</a>
|
|
</ul>
|
|
<hr><h2>Class Methods </h2>
|
|
<h3><a name ="method-0">launchedTaskWithLaunchPath:arguments:</a></h3>
|
|
+ (NSTask*) <b>launchedTaskWithLaunchPath:</b> (NSString*)path <b>arguments:</b> (NSArray*)arguments;<br>
|
|
|
|
Creates and launches a task, returning an autoreleased task object.
|
|
Supplies the path to the executable and an array of argument.
|
|
The task inherits the parents environment and I/O.
|
|
|
|
<hr>
|
|
<hr><h2>Instances Methods </h2>
|
|
<h3><a name ="method-1">arguments</a></h3>
|
|
- (NSArray*) <b>arguments</b>;<br>
|
|
|
|
Returns the arguments set for the task.
|
|
|
|
<hr>
|
|
<h3><a name ="method-2">currentDirectoryPath</a></h3>
|
|
- (NSString*) <b>currentDirectoryPath</b>;<br>
|
|
|
|
Returns the working directory set for the task.
|
|
|
|
<hr>
|
|
<h3><a name ="method-3">environment</a></h3>
|
|
- (NSDictionary*) <b>environment</b>;<br>
|
|
|
|
Returns the environment set for the task.
|
|
|
|
<hr>
|
|
<h3><a name ="method-4">interrupt</a></h3>
|
|
- (void) <b>interrupt</b>;<br>
|
|
|
|
Sends an interrupt signal to the receiver and any subtasks.<br>
|
|
If the task has not been launched, raises an
|
|
NSInvalidArgumentException.<br>
|
|
Has no effect on a task that has already terminated.<br>
|
|
This is rather like the terminate method, but the child
|
|
process may not choose to terminate in response to an interrupt.
|
|
|
|
<hr>
|
|
<h3><a name ="method-5">isRunning</a></h3>
|
|
- (BOOL) <b>isRunning</b>;<br>
|
|
|
|
Checks to see if the task is currently running.
|
|
|
|
<hr>
|
|
<h3><a name ="method-6">launch</a></h3>
|
|
- (void) <b>launch</b>;<br>
|
|
|
|
Launches the task.<br>
|
|
Raises an NSInvalidArgumentException if the launch path is not
|
|
set or if the subtask cannot be started for some reason
|
|
(eg. the executable does not exist).
|
|
|
|
<hr>
|
|
<h3><a name ="method-7">launchPath</a></h3>
|
|
- (NSString*) <b>launchPath</b>;<br>
|
|
|
|
Returns the launch path set for the task.
|
|
|
|
<hr>
|
|
<h3><a name ="method-8">processIdentifer</a></h3>
|
|
- (int) <b>processIdentifer</b>;<br>
|
|
|
|
Returns the number identifying the child process on this system.
|
|
|
|
<hr>
|
|
<h3><a name ="method-9">setArguments:</a></h3>
|
|
- (void) <b>setArguments:</b> (NSArray*)arguments;<br>
|
|
|
|
Sets an array of arguments to be supplied to the task when it
|
|
is launched. The default is an empty array. This method cannot
|
|
be used after a task is launched ...
|
|
it raises an NSInvalidArgumentException.
|
|
|
|
<hr>
|
|
<h3><a name ="method-10">setCurrentDirectoryPath:</a></h3>
|
|
- (void) <b>setCurrentDirectoryPath:</b> (NSString*)path;<br>
|
|
|
|
Sets the home directory in which the task is to be run.
|
|
The default is the parent processes directory.
|
|
This method cannot be used after a task is launched ...
|
|
it raises an NSInvalidArgumentException.
|
|
|
|
<hr>
|
|
<h3><a name ="method-11">setEnvironment:</a></h3>
|
|
- (void) <b>setEnvironment:</b> (NSDictionary*)environmentDictionary;<br>
|
|
|
|
Sets the environment variables for the task to be run.
|
|
The default is the parent processes environment.
|
|
This method cannot be used after a task is launched ...
|
|
it raises an NSInvalidArgumentException.
|
|
|
|
<hr>
|
|
<h3><a name ="method-12">setLaunchPath:</a></h3>
|
|
- (void) <b>setLaunchPath:</b> (NSString*)path;<br>
|
|
|
|
Sets the path to the executable file to be run.
|
|
There is no default for this - you must set the launch path.
|
|
This method cannot be used after a task is launched ...
|
|
it raises an NSInvalidArgumentException.
|
|
|
|
<hr>
|
|
<h3><a name ="method-13">setStandardError:</a></h3>
|
|
- (void) <b>setStandardError:</b> (id)file;<br>
|
|
|
|
Sets the standard error stream for the task.<br>
|
|
This is normally a writable NSFileHandle object.
|
|
If this is an NSPipe, the write end of the pipe is
|
|
automatically closed on launching.<br>
|
|
The default behavior is to inherit the parent processes
|
|
stderr output.<br>
|
|
This method cannot be used after a task is launched ...
|
|
it raises an NSInvalidArgumentException.
|
|
|
|
<hr>
|
|
<h3><a name ="method-14">setStandardInput:</a></h3>
|
|
- (void) <b>setStandardInput:</b> (id)file;<br>
|
|
|
|
Sets the standard input stream for the task.<br>
|
|
This is normally a readable NSFileHandle object.
|
|
If this is an NSPipe, the read end of the pipe is
|
|
automatically closed on launching.<br>
|
|
The default behavior is to inherit the parent processes
|
|
stdin stream.<br>
|
|
This method cannot be used after a task is launched ...
|
|
it raises an NSInvalidArgumentException.
|
|
|
|
<hr>
|
|
<h3><a name ="method-15">setStandardOutput:</a></h3>
|
|
- (void) <b>setStandardOutput:</b> (id)file;<br>
|
|
|
|
Sets the standard output stream for the task.<br>
|
|
This is normally a writable NSFileHandle object.
|
|
If this is an NSPipe, the write end of the pipe is
|
|
automatically closed on launching.<br>
|
|
The default behavior is to inherit the parent processes
|
|
stdout stream.<br>
|
|
This method cannot be used after a task is launched ...
|
|
it raises an NSInvalidArgumentException.
|
|
|
|
<hr>
|
|
<h3><a name ="method-16">standardError</a></h3>
|
|
- (id) <b>standardError</b>;<br>
|
|
|
|
Returns the standard error stream for the task - an NSFileHandle
|
|
unless an NSPipe was passed to setStandardError:
|
|
|
|
<hr>
|
|
<h3><a name ="method-17">standardInput</a></h3>
|
|
- (id) <b>standardInput</b>;<br>
|
|
|
|
Returns the standard input stream for the task - an NSFileHandle
|
|
unless an NSPipe was passed to setStandardInput:
|
|
|
|
<hr>
|
|
<h3><a name ="method-18">standardOutput</a></h3>
|
|
- (id) <b>standardOutput</b>;<br>
|
|
|
|
Returns the standard output stream for the task - an NSFileHandle
|
|
unless an NSPipe was passed to setStandardOutput:
|
|
|
|
<hr>
|
|
<h3><a name ="method-19">resume</a></h3>
|
|
- (BOOL) <b>resume</b>;<br>
|
|
|
|
Sends a cont signal to the receiver and any subtasks.<br>
|
|
If the task has not been launched, raises an
|
|
NSInvalidArgumentException.<br>
|
|
|
|
<hr>
|
|
<h3><a name ="method-20">suspend</a></h3>
|
|
- (BOOL) <b>suspend</b>;<br>
|
|
|
|
Sends a stop signal to the receiver and any subtasks.<br>
|
|
If the task has not been launched, raises an
|
|
NSInvalidArgumentException.<br>
|
|
|
|
<hr>
|
|
<h3><a name ="method-21">terminate</a></h3>
|
|
- (void) <b>terminate</b>;<br>
|
|
|
|
Sends a terminate signal to the receiver and any subtasks.<br>
|
|
If the task has not been launched, raises an
|
|
NSInvalidArgumentException.<br>
|
|
Has no effect on a task that has already terminated.<br>
|
|
When a task temrinates, either due to this method being called,
|
|
or normal termination, an NSTaskDidTerminateNotification is
|
|
posted.
|
|
|
|
<hr>
|
|
<h3><a name ="method-22">terminationStatus</a></h3>
|
|
- (int) <b>terminationStatus</b>;<br>
|
|
|
|
Returns the termination status of the task.<br>
|
|
If the task has not completed running, raises an
|
|
NSInvalidArgumentException.
|
|
|
|
<hr>
|
|
<h3><a name ="method-23">usePseudoTerminal</a></h3>
|
|
- (BOOL) <b>usePseudoTerminal</b>;<br>
|
|
Standards: GNUstep NotMacOS-X NotOpenStep<br>
|
|
|
|
If the system supports it, this method sets the standard
|
|
input, output, and error streams to a pseudo-terminal so
|
|
that, when launched, the child task will act as if it was
|
|
running interactively on a terminal. The file handles
|
|
can then be used to communicate with the child.<br>
|
|
This method cannot be used after a task is launched ...
|
|
it raises an NSInvalidArgumentException.<br>
|
|
The standard input, output and error streams cannot be
|
|
changed after calling this method.<br>
|
|
The method returns YES on success, NO on failure.
|
|
|
|
<hr>
|
|
<h3><a name ="method-24">waitUntilExit</a></h3>
|
|
- (void) <b>waitUntilExit</b>;<br>
|
|
|
|
Suspends the current thread until the task terminates, by
|
|
waiting in NSRunLoop (NSDefaultRunLoopMode) for the task
|
|
termination.<br>
|
|
Returns immediately if the task is not running.
|
|
|
|
<hr>
|
|
</body>
|
|
|
|
</html>
|