mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-04 10:30:47 +00:00
reorganise a little avoiding redundant system calls (setpgrp and ioctl TIOCNOTTY
are not needed if setsid is used). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29334 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
68e92f70ad
commit
f0aa4a6bf3
1 changed files with 24 additions and 39 deletions
|
@ -1495,35 +1495,48 @@ GSPrivateCheckTasks()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/* Make sure the task gets default signal setup.
|
||||||
* Make sure the task gets default signal setup.
|
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < 32; i++)
|
for (i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
signal(i, SIG_DFL);
|
signal(i, SIG_DFL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Make sure task is session leader in it's own process group
|
||||||
* Make sure task is run in it's own process group.
|
* and with no controlling terminal.
|
||||||
* This allows us to use killpg() to put the task to sleep etc,
|
* This allows us to use killpg() to put the task to sleep etc,
|
||||||
* and have the signal effect forked children of the subtask.
|
* and have the signal effect forked children of the subtask.
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_SETPGRP
|
#if defined(HAVE_SETSID)
|
||||||
#ifdef SETPGRP_VOID
|
setsid();
|
||||||
|
#else
|
||||||
|
#if defined(HAVE_SETPGRP)
|
||||||
|
#if defined(SETPGRP_VOID)
|
||||||
setpgrp();
|
setpgrp();
|
||||||
#else
|
#else
|
||||||
setpgrp(getpid(), getpid());
|
setpgrp(getpid(), getpid());
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
#if defined(HAVE_SETPGID)
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__)
|
||||||
pid = (int)GetCurrentProcessId(),
|
pid = (int)GetCurrentProcessId(),
|
||||||
#else
|
#else
|
||||||
pid = (int)getpid();
|
pid = (int)getpid();
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SETPGID
|
|
||||||
setpgid(pid, pid);
|
setpgid(pid, pid);
|
||||||
#endif
|
#endif /* HAVE_SETPGID */
|
||||||
#endif
|
#endif /* HAVE_SETPGRP */
|
||||||
|
/* Detach from controlling terminal.
|
||||||
|
*/
|
||||||
|
#if defined(TIOCNOTTY)
|
||||||
|
i = open("/dev/tty", O_RDWR);
|
||||||
|
if (i >= 0)
|
||||||
|
{
|
||||||
|
(void)ioctl(i, TIOCNOTTY, 0);
|
||||||
|
(void)close(i);
|
||||||
|
}
|
||||||
|
#endif /* TIOCNOTTY */
|
||||||
|
#endif /* HAVE_SETSID */
|
||||||
|
|
||||||
if (_usePseudoTerminal == YES)
|
if (_usePseudoTerminal == YES)
|
||||||
{
|
{
|
||||||
|
@ -1535,21 +1548,7 @@ GSPrivateCheckTasks()
|
||||||
exit(1); /* Failed to open slave! */
|
exit(1); /* Failed to open slave! */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Detach from controlling terminal.
|
/* Set up stdin, stdout and stderr by duplicating descriptors as
|
||||||
*/
|
|
||||||
#ifdef HAVE_SETSID
|
|
||||||
i = setsid();
|
|
||||||
#endif
|
|
||||||
#ifdef TIOCNOTTY
|
|
||||||
i = open("/dev/tty", O_RDWR);
|
|
||||||
if (i >= 0)
|
|
||||||
{
|
|
||||||
(void)ioctl(i, TIOCNOTTY, 0);
|
|
||||||
(void)close(i);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* Set up stdin, stdout and stderr by duplicating descriptors as
|
|
||||||
* necessary and closing the originals (to ensure we won't have a
|
* necessary and closing the originals (to ensure we won't have a
|
||||||
* pipe left with two write descriptors etc).
|
* pipe left with two write descriptors etc).
|
||||||
*/
|
*/
|
||||||
|
@ -1568,21 +1567,7 @@ GSPrivateCheckTasks()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Detach from controlling terminal.
|
/* Set up stdin, stdout and stderr by duplicating descriptors as
|
||||||
*/
|
|
||||||
#ifdef HAVE_SETSID
|
|
||||||
i = setsid();
|
|
||||||
#endif
|
|
||||||
#ifdef TIOCNOTTY
|
|
||||||
i = open("/dev/tty", O_RDWR);
|
|
||||||
if (i >= 0)
|
|
||||||
{
|
|
||||||
(void)ioctl(i, TIOCNOTTY, 0);
|
|
||||||
(void)close(i);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* Set up stdin, stdout and stderr by duplicating descriptors as
|
|
||||||
* necessary and closing the originals (to ensure we won't have a
|
* necessary and closing the originals (to ensure we won't have a
|
||||||
* pipe left with two write descriptors etc).
|
* pipe left with two write descriptors etc).
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue