1998-01-19 15:20:15 +00:00
|
|
|
/* Interface for NSTask for GNUstep
|
|
|
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Date: 1998
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1998-01-19 15:20:15 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
1998-01-19 15:20:15 +00:00
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1998-01-19 15:20:15 +00:00
|
|
|
License along with this library; if not, write to the Free
|
2006-10-31 07:05:46 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
1998-01-19 15:20:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NSTask_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSTask_h_GNUSTEP_BASE_INCLUDE
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
1998-01-19 15:20:15 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <Foundation/NSObject.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSFileHandle.h>
|
1998-01-19 15:20:15 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-04-09 09:56:55 +00:00
|
|
|
@class NSThread;
|
|
|
|
|
2016-06-26 05:56:10 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST)
|
|
|
|
enum {
|
|
|
|
NSTaskTerminationReasonExit = 1,
|
|
|
|
NSTaskTerminationReasonUncaughtSignal = 2
|
|
|
|
};
|
|
|
|
typedef NSInteger NSTaskTerminationReason;
|
|
|
|
#endif
|
|
|
|
|
2009-01-12 18:36:37 +00:00
|
|
|
@interface NSTask : NSObject
|
1998-01-19 15:20:15 +00:00
|
|
|
{
|
2010-02-14 10:48:10 +00:00
|
|
|
#if GS_EXPOSE(NSTask)
|
|
|
|
@protected
|
1999-09-16 07:21:34 +00:00
|
|
|
NSString *_currentDirectoryPath;
|
|
|
|
NSString *_launchPath;
|
|
|
|
NSArray *_arguments;
|
|
|
|
NSDictionary *_environment;
|
|
|
|
id _standardError;
|
|
|
|
id _standardInput;
|
|
|
|
id _standardOutput;
|
|
|
|
int _taskId;
|
|
|
|
int _terminationStatus;
|
|
|
|
BOOL _hasLaunched;
|
|
|
|
BOOL _hasTerminated;
|
|
|
|
BOOL _hasCollected;
|
|
|
|
BOOL _hasNotified;
|
2017-04-09 09:56:55 +00:00
|
|
|
NSThread *_launchingThread;
|
2016-06-26 05:56:10 +00:00
|
|
|
NSTaskTerminationReason _terminationReason;
|
2010-03-02 09:51:12 +00:00
|
|
|
#endif
|
2011-02-16 05:49:45 +00:00
|
|
|
#if GS_NONFRAGILE
|
|
|
|
#else
|
2011-02-14 06:37:45 +00:00
|
|
|
/* Pointer to private additional data used to avoid breaking ABI
|
|
|
|
* when we don't have the non-fragile ABI available.
|
2011-02-16 05:49:45 +00:00
|
|
|
* Use this mechanism rather than changing the instance variable
|
|
|
|
* layout (see Source/GSInternal.h for details).
|
2011-02-14 06:37:45 +00:00
|
|
|
*/
|
2011-03-05 18:12:55 +00:00
|
|
|
@private id _internal GS_UNUSED_IVAR;
|
2011-02-14 06:37:45 +00:00
|
|
|
#endif
|
1998-01-19 15:20:15 +00:00
|
|
|
}
|
|
|
|
|
1998-12-16 20:32:59 +00:00
|
|
|
+ (NSTask*) launchedTaskWithLaunchPath: (NSString*)path
|
|
|
|
arguments: (NSArray*)args;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Querying task parameters.
|
|
|
|
*/
|
|
|
|
- (NSArray*) arguments;
|
|
|
|
- (NSString*) currentDirectoryPath;
|
|
|
|
- (NSDictionary*) environment;
|
|
|
|
- (NSString*) launchPath;
|
1998-12-16 20:32:59 +00:00
|
|
|
- (id) standardError;
|
|
|
|
- (id) standardInput;
|
|
|
|
- (id) standardOutput;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setting task parameters.
|
|
|
|
*/
|
1998-12-16 20:32:59 +00:00
|
|
|
- (void) setArguments: (NSArray*)args;
|
|
|
|
- (void) setCurrentDirectoryPath: (NSString*)path;
|
|
|
|
- (void) setEnvironment: (NSDictionary*)env;
|
|
|
|
- (void) setLaunchPath: (NSString*)path;
|
|
|
|
- (void) setStandardError: (id)hdl;
|
|
|
|
- (void) setStandardInput: (id)hdl;
|
|
|
|
- (void) setStandardOutput: (id)hdl;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Obtaining task state
|
|
|
|
*/
|
|
|
|
- (BOOL) isRunning;
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
2001-07-15 09:08:27 +00:00
|
|
|
- (int) processIdentifier;
|
|
|
|
#endif
|
2016-06-26 05:56:10 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST)
|
|
|
|
- (NSTaskTerminationReason) terminationReason;
|
|
|
|
#endif
|
1998-01-19 15:20:15 +00:00
|
|
|
- (int) terminationStatus;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handling a task.
|
|
|
|
*/
|
|
|
|
- (void) interrupt;
|
|
|
|
- (void) launch;
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
2001-07-15 09:08:27 +00:00
|
|
|
- (BOOL) resume;
|
|
|
|
- (BOOL) suspend;
|
|
|
|
#endif
|
1998-01-19 15:20:15 +00:00
|
|
|
- (void) terminate;
|
|
|
|
- (void) waitUntilExit;
|
2001-02-05 09:28:19 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
|
2001-02-05 09:28:19 +00:00
|
|
|
- (BOOL) usePseudoTerminal;
|
2002-02-08 13:13:46 +00:00
|
|
|
- (NSString*) validatedLaunchPath;
|
2001-02-05 09:28:19 +00:00
|
|
|
#endif
|
1998-01-19 15:20:15 +00:00
|
|
|
@end
|
|
|
|
|
2004-07-29 15:30:47 +00:00
|
|
|
/**
|
|
|
|
* Notification posted when an [NSTask] terminates, either due to the
|
|
|
|
* subprocess ending or the [NSTask-terminate] method explicitly being
|
|
|
|
* called.
|
|
|
|
*/
|
2004-09-19 23:19:53 +00:00
|
|
|
GS_EXPORT NSString* const NSTaskDidTerminateNotification;
|
1998-01-19 15:20:15 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-02-20 17:16:23 +00:00
|
|
|
#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL)
|
2010-02-18 11:40:58 +00:00
|
|
|
#import <GNUstepBase/NSTask+GNUstepBase.h>
|
|
|
|
#endif
|
|
|
|
|
1998-01-19 15:20:15 +00:00
|
|
|
#endif /* __NSTask_h_GNUSTEP_BASE_INCLUDE */
|