Various minor updatesw for MacOS-X compatibility.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10481 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2001-07-15 09:08:27 +00:00
parent 23088ba48e
commit d9cc3cb96e
7 changed files with 103 additions and 18 deletions

View file

@ -1,3 +1,12 @@
2001-07-15 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSProcessInfo.m: Added -processIdentifier for compatibility
with MacOS-X
* Source/NSTask.m: Added -processIdentifier, -suspend, and -resume
for compatibility with MacOS-X
* Source/NSPortNameServer.m: Modified removal methods to return a
boolean success/failure status for MacOS-X compatibility.
2001-07-14 Adam Fedor <fedor@gnu.org>
* Headers/gnustep/base/objc-gnu2next.h: More function defs.

View file

@ -39,14 +39,14 @@
onHost: (NSString*)host;
- (BOOL) registerPort: (NSPort*)port
forName: (NSString*)name;
- (void) removePortForName: (NSString*)name;
- (BOOL) removePortForName: (NSString*)name;
@end
#ifndef NO_GNUSTEP
@interface NSPortNameServer (GNUstep)
- (NSArray*) namesForPort: (NSPort*)port; /* return all names for port */
- (void) removePort: (NSPort*)port; /* remove all names for port */
- (void) removePort: (NSPort*)port forName: (NSString*)name;
- (BOOL) removePort: (NSPort*)port; /* remove all names for port */
- (BOOL) removePort: (NSPort*)port forName: (NSString*)name;
@end
#endif

View file

@ -37,17 +37,20 @@
@interface NSProcessInfo: NSObject
/* Getting an NSProcessInfo Object */
+ (NSProcessInfo *)processInfo;
+ (NSProcessInfo*) processInfo;
/* Returning Process Information */
- (NSArray *)arguments;
- (NSDictionary *)environment;
- (NSString *)hostName;
- (NSString *)processName;
- (NSString *)globallyUniqueString;
- (NSArray*) arguments;
- (NSDictionary*) environment;
- (NSString*) hostName;
#ifndef STRICT_OPENSTEP
- (int) processIdentifier;
#endif
- (NSString*) processName;
- (NSString*) globallyUniqueString;
/* Specifying a Process Name */
- (void)setProcessName:(NSString *)newName;
- (void) setProcessName: (NSString*)newName;
@end
@ -59,9 +62,9 @@
- (NSMutableSet*) debugSet;
/* When non using the other argument initialization hacks... */
+ (void)initializeWithArguments:(char**)argv
count:(int)argc
environment:(char**)env;
+ (void)initializeWithArguments: (char**)argv
count: (int)argc
environment: (char**)env;
@end
/*

View file

@ -76,6 +76,9 @@
* Obtaining task state
*/
- (BOOL) isRunning;
#ifndef STRICT_OPENSTEP
- (int) processIdentifier;
#endif
- (int) terminationStatus;
/*
@ -83,6 +86,10 @@
*/
- (void) interrupt;
- (void) launch;
#ifndef STRICT_OPENSTEP
- (BOOL) resume;
- (BOOL) suspend;
#endif
- (void) terminate;
- (void) waitUntilExit;

View file

@ -934,12 +934,13 @@ typedef enum {
return YES;
}
- (void) removePortForName: (NSString*)name
- (BOOL) removePortForName: (NSString*)name
{
NSRunLoop *loop = [NSRunLoop currentRunLoop];
GSPortCom *com = nil;
unsigned len;
NSDate *limit = [NSDate dateWithTimeIntervalSinceNow: timeout];
BOOL val = NO;
if (name == nil)
{
@ -990,6 +991,7 @@ typedef enum {
if (result == 0)
{
NSLog(@"NSPortNameServer unable to unregister '%@'", name);
val = NO;
}
else
{
@ -1015,6 +1017,7 @@ typedef enum {
}
}
}
val = YES;
}
}
tmp = com;
@ -1032,6 +1035,7 @@ typedef enum {
}
NS_ENDHANDLER
[serverLock unlock];
return val;
}
@end
@ -1070,8 +1074,9 @@ typedef enum {
* Remove all names for a particular port - used when a port is
* invalidated.
*/
- (void) removePort: (NSPort*)port
- (BOOL) removePort: (NSPort*)port
{
BOOL ok = YES;
[serverLock lock];
NS_DURING
{
@ -1080,7 +1085,10 @@ typedef enum {
while ((name = [known anyObject]) != nil)
{
[self removePortForName: name];
if ([self removePortForName: name] == NO)
{
ok = NO;
}
}
}
NS_HANDLER
@ -1090,13 +1098,16 @@ typedef enum {
}
NS_ENDHANDLER
[serverLock unlock];
return ok;
}
/*
* Remove name for port iff it is registered.
*/
- (void) removePort: (NSPort*)port forName: (NSString*)name
- (BOOL) removePort: (NSPort*)port forName: (NSString*)name
{
BOOL ok = YES;
[serverLock lock];
NS_DURING
{
@ -1104,7 +1115,10 @@ typedef enum {
if ([known member: name] != nil)
{
[self removePortForName: name];
if ([self removePortForName: name] == NO)
{
ok = NO;
}
}
}
NS_HANDLER
@ -1114,6 +1128,7 @@ typedef enum {
}
NS_ENDHANDLER
[serverLock unlock];
return ok;
}
@end

View file

@ -578,6 +578,18 @@ int main(int argc, char *argv[], char *env[])
return _gnu_hostName;
}
- (int) processIdentifier
{
int pid;
#if defined(__MINGW__)
pid = (int)GetCurrentProcessId();
#else
pid = (int)getpid();
#endif
return pid;
}
- (NSString *) processName
{
return _gnu_processName;

View file

@ -439,6 +439,11 @@ pty_slave(const char* name)
return YES;
}
- (int) processIdentifier
{
return _taskId;
}
- (int) terminationStatus
{
if (_hasLaunched == NO)
@ -487,6 +492,40 @@ pty_slave(const char* name)
[self subclassResponsibility: _cmd];
}
- (BOOL) resume
{
if (_hasLaunched == NO)
{
[NSException raise: NSInvalidArgumentException
format: @"NSTask - task has not yet launched"];
}
#ifndef __MINGW__
#ifdef HAVE_KILLPG
killpg(_taskId, SIGCONT);
#else
kill(-_taskId, SIGCONT);
#endif
#endif
return YES;
}
- (BOOL) suspend
{
if (_hasLaunched == NO)
{
[NSException raise: NSInvalidArgumentException
format: @"NSTask - task has not yet launched"];
}
#ifndef __MINGW__
#ifdef HAVE_KILLPG
killpg(_taskId, SIGTERM);
#else
kill(-_taskId, SIGTERM);
#endif
#endif
return YES;
}
- (void) terminate
{
if (_hasLaunched == NO)