Minor bugfixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4084 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-04-15 09:28:37 +00:00
parent 12458af627
commit c5ddf72b9d
3 changed files with 35 additions and 11 deletions

View file

@ -1,3 +1,10 @@
Thu Apr 15 9:47:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/UnixFileHandle.m: ([-fileDescriptor]) return a valid file
descriptor (for /dev/null) for the null device.
* Source/NSTask.m: ([-launch]) Add code to reset signals in subprocess
and to close all file descriptors (except stdin, stdout and stderr).
Wed Apr 14 14:32:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSPortNameServer.m: Don't suspend thread while waiting for

View file

@ -41,8 +41,16 @@
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/wait.h>
/*
* If we don't have NFILE, default to 256 open descriptors.
*/
#ifndef NOFILE
#define NOFILE 256
#endif
NSString *NSTaskDidTerminateNotification = @"NSTaskDidTerminateNotification";
static NSRecursiveLock *tasksLock = nil;
@ -490,6 +498,19 @@ extern char *objc_find_executable(const char *name);
}
if (pid == 0)
{
int i;
/*
* Make sure the task gets default signal setup.
*/
for (i = 0; i < 32; i++)
{
signal(i, SIG_DFL);
}
/*
* Make sure task is run in it's own process group.
*/
#if HAVE_SETPGRP
setpgrp();
#else
@ -498,6 +519,7 @@ extern char *objc_find_executable(const char *name);
setpgid(pid, pid);
#endif
#endif
/*
* Set up stdin, stdout and stderr by duplicating descriptors as
* necessary and closing the originals (to ensure we won't have a
@ -506,24 +528,21 @@ extern char *objc_find_executable(const char *name);
if (idesc != 0)
{
dup2(idesc, 0);
if (idesc != odesc && idesc != edesc)
{
(void) close(idesc);
}
}
if (odesc != 1)
{
dup2(odesc, 1);
if (odesc != edesc)
{
(void) close(odesc);
}
}
if (edesc != 2)
{
dup2(edesc, 2);
(void) close(edesc);
}
for (i = 3; i < NOFILE; i++)
{
(void) close(i);
}
chdir(path);
execve(executable, args, envl);
exit(-1);

View file

@ -636,8 +636,6 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
- (int)fileDescriptor
{
if (isNullDevice)
return -1;
return descriptor;
}