Remove support for old and buggy SCO systems. Optimize a bit for use in glibc.

This commit is contained in:
Ulrich Drepper 2002-10-12 20:24:30 +00:00
parent 75b04e6c0b
commit 20f3b1275d
1 changed files with 11 additions and 26 deletions

View File

@ -52,18 +52,9 @@ do_system (const char *line)
if (__sigaction (SIGQUIT, &sa, &quit) < 0) if (__sigaction (SIGQUIT, &sa, &quit) < 0)
{ {
save = errno; save = errno;
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); goto out_restore_sigint;
__set_errno (save);
return -1;
} }
#ifndef WAITPID_CANNOT_BLOCK_SIGCHLD
/* SCO 3.2v4 has a bug where `waitpid' will never return if SIGCHLD is
blocked. This makes it impossible for `system' to be implemented in
compliance with POSIX.2-1992. They have acknowledged that this is a bug
but I have not seen nor heard of any forthcoming fix. */
__sigemptyset (&block); __sigemptyset (&block);
__sigaddset (&block, SIGCHLD); __sigaddset (&block, SIGCHLD);
save = errno; save = errno;
@ -74,16 +65,13 @@ do_system (const char *line)
else else
{ {
save = errno; save = errno;
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
out_restore_sigint:
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
__set_errno (save); __set_errno (save);
return -1; return -1;
} }
} }
# define UNBLOCK __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)
#else
# define UNBLOCK 0
#endif
pid = __fork (); pid = __fork ();
if (pid == (pid_t) 0) if (pid == (pid_t) 0)
@ -98,7 +86,7 @@ do_system (const char *line)
/* Restore the signals. */ /* Restore the signals. */
(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
(void) UNBLOCK; (void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
/* Exec the shell. */ /* Exec the shell. */
(void) __execve (SHELL_PATH, (char *const *) new_argv, __environ); (void) __execve (SHELL_PATH, (char *const *) new_argv, __environ);
@ -125,25 +113,22 @@ do_system (const char *line)
} }
while (child != pid); while (child != pid);
#else #else
int n; if (TEMP_FAILURE_RETRY (__waitpid (pid, &status, 0)) != pid)
do
n = __waitpid (pid, &status, 0);
while (n == -1 && errno == EINTR);
if (n != pid)
status = -1; status = -1;
#endif #endif
} }
save = errno; save = errno;
if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) | if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
__sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) | | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
UNBLOCK) != 0) | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0)
{ {
#ifndef _LIBC
/* glibc cannot be used on systems without waitpid. */
if (errno == ENOSYS) if (errno == ENOSYS)
__set_errno (save); __set_errno (save);
else else
#endif
return -1; return -1;
} }