Formerly job.c.~70~

This commit is contained in:
Roland McGrath 1992-06-11 05:25:28 +00:00
parent 59caea5674
commit b6364d9ae4

66
job.c
View file

@ -31,23 +31,19 @@ char default_shell[] = "/bin/sh";
extern int errno; extern int errno;
#if defined(POSIX) || defined(__GNU_LIBRARY__) #ifndef NGROUPS_MAX
#include <limits.h> #ifdef POSIX
#include <unistd.h>
#define GET_NGROUPS_MAX sysconf (_SC_NGROUPS_MAX) #define GET_NGROUPS_MAX sysconf (_SC_NGROUPS_MAX)
#else /* Not POSIX. */ #else /* Not POSIX. */
#ifndef USG
#include <sys/param.h>
#define NGROUPS_MAX NGROUPS #define NGROUPS_MAX NGROUPS
#endif /* Not USG. */
#endif /* POSIX. */ #endif /* POSIX. */
#ifdef POSIX #ifdef HAVE_WAITPID
#include <sys/wait.h> #include <sys/wait.h>
#define WAIT_NOHANG(status) waitpid(-1, (status), WNOHANG) #define WAIT_NOHANG(status) waitpid(-1, (status), WNOHANG)
#else /* Not POSIX. */ #else /* Don't have waitpid. */
#if defined(HAVE_SYS_WAIT) || !defined(USG) #if defined(HAVE_SYS_WAIT) || !defined(USG)
#include <sys/wait.h> #include <sys/wait.h>
@ -64,7 +60,7 @@ extern int wait3 ();
extern int wait (); extern int wait ();
#endif #endif
#endif /* HAVE_SYS_WAIT || !USG */ #endif /* HAVE_SYS_WAIT || !USG */
#endif /* POSIX. */ #endif /* Have waitpid. */
#if defined(WTERMSIG) || (defined(USG) && !defined(HAVE_SYS_WAIT)) #if defined(WTERMSIG) || (defined(USG) && !defined(HAVE_SYS_WAIT))
#define WAIT_T int #define WAIT_T int
@ -101,24 +97,16 @@ extern int wait ();
#endif /* WTERMSIG defined or USG and don't have <sys/wait.h>. */ #endif /* WTERMSIG defined or USG and don't have <sys/wait.h>. */
#if defined(__GNU_LIBRARY__) || defined(POSIX) #ifndef HAVE_UNISTD_H
#include <sys/types.h>
#define GID_T gid_t
#else /* Not GNU C library. */
#define GID_T int
extern int dup2 (); extern int dup2 ();
extern int execve (); extern int execve ();
extern void _exit (); extern void _exit ();
extern int geteuid (), getegid (); extern int geteuid (), getegid ();
extern int setgid (), getgid (); extern int setgid (), getgid ();
#endif /* GNU C library. */ #endif
#ifndef getdtablesize #ifndef getdtablesize
#ifndef USG #ifndef GETDTABLESIZE_MISSING
extern int getdtablesize (); extern int getdtablesize ();
#else #else
#include <sys/param.h> #include <sys/param.h>
@ -131,12 +119,12 @@ extern int start_remote_job_p ();
extern int start_remote_job (), remote_status (); extern int start_remote_job (), remote_status ();
#if (defined(USG) && !defined(HAVE_SIGLIST)) || defined(DGUX) #ifdef SYS_SIGLIST_MISSING
static char *sys_siglist[NSIG]; static char *sys_siglist[NSIG];
void init_siglist (); void init_siglist ();
#else /* Not (USG and HAVE_SIGLIST), or DGUX. */ #else
extern char *sys_siglist[]; extern char *sys_siglist[];
#endif /* USG and not HAVE_SIGLIST, or DGUX. */ #endif
int child_handler (); int child_handler ();
static void free_child (), start_job (); static void free_child (), start_job ();
@ -182,7 +170,7 @@ static unsigned int dead_children = 0;
/* Notice that a child died. /* Notice that a child died.
reap_children should be called when convenient. */ reap_children should be called when convenient. */
int RETSIGTYPE
child_handler (sig) child_handler (sig)
int sig; int sig;
{ {
@ -433,7 +421,7 @@ unblock_sigs ()
sigprocmask (SIG_SETMASK, &empty, (sigset_t *) 0); sigprocmask (SIG_SETMASK, &empty, (sigset_t *) 0);
} }
#else #else
#ifndef USG #ifndef SIGSETMASK_MISSING
extern int fatal_signal_mask; extern int fatal_signal_mask;
#define unblock_sigs() sigsetmask (0) #define unblock_sigs() sigsetmask (0)
#else #else
@ -605,7 +593,7 @@ start_job (child)
#ifdef POSIX #ifdef POSIX
(void) sigprocmask (SIG_BLOCK, &fatal_signal_set, (sigset_t *) 0); (void) sigprocmask (SIG_BLOCK, &fatal_signal_set, (sigset_t *) 0);
#else #else
#ifndef USG #ifndef SIGSETMASK_MISSING
(void) sigblock (fatal_signal_mask); (void) sigblock (fatal_signal_mask);
#endif #endif
#endif #endif
@ -623,7 +611,7 @@ start_job (child)
{ {
/* Fork failed! */ /* Fork failed! */
unblock_sigs (); unblock_sigs ();
perror_with_name (VFORK_NAME, ""); perror_with_name ("vfork", "");
goto error; goto error;
} }
} }
@ -765,26 +753,26 @@ search_path (file, path, program)
{ {
unsigned int len; unsigned int len;
#if !defined (USG) || defined (POSIX) #ifndef GETGROUPS_MISSING
#ifndef POSIX #ifndef HAVE_UNISTD_H
extern int getgroups (); extern int getgroups ();
#endif #endif
static int ngroups = -1; static int ngroups = -1;
#ifdef NGROUPS_MAX #ifdef NGROUPS_MAX
static GID_T groups[NGROUPS_MAX]; static gid_t groups[NGROUPS_MAX];
#define ngroups_max NGROUPS_MAX #define ngroups_max NGROUPS_MAX
#else #else
static GID_T *groups = 0; static gid_t *groups = 0;
static int ngroups_max; static int ngroups_max;
if (groups == 0) if (groups == 0)
{ {
ngroups_max = GET_NGROUPS_MAX; ngroups_max = GET_NGROUPS_MAX;
groups = (GID_T *) malloc (ngroups_max * sizeof (GID_T)); groups = (gid_t *) malloc (ngroups_max * sizeof (gid_t));
} }
#endif #endif
if (groups != 0 && ngroups == -1) if (groups != 0 && ngroups == -1)
ngroups = getgroups (ngroups_max, groups); ngroups = getgroups (ngroups_max, groups);
#endif /* POSIX or not USG. */ #endif /* getgroups missing. */
len = strlen (file) + 1; len = strlen (file) + 1;
do do
@ -815,7 +803,7 @@ search_path (file, path, program)
perm = (st.st_mode & 0010); perm = (st.st_mode & 0010);
else else
{ {
#ifndef USG #ifndef GETGROUPS_MISSING
register int i; register int i;
for (i = 0; i < ngroups; ++i) for (i = 0; i < ngroups; ++i)
if (groups[i] == st.st_gid) if (groups[i] == st.st_gid)
@ -823,7 +811,7 @@ search_path (file, path, program)
if (i < ngroups) if (i < ngroups)
perm = (st.st_mode & 0010); perm = (st.st_mode & 0010);
else else
#endif /* Not USG. */ #endif /* getgroups missing. */
perm = (st.st_mode & 0001); perm = (st.st_mode & 0001);
} }
@ -1198,7 +1186,7 @@ construct_command_argv (line, restp, file)
return argv; return argv;
} }
#if (defined(USG) && !defined(HAVE_SIGLIST)) || defined(DGUX) #ifdef SYS_SIGLIST_MISSING
/* Initialize sys_siglist. */ /* Initialize sys_siglist. */
void void
@ -1351,9 +1339,9 @@ init_siglist ()
#endif #endif
} }
} }
#endif /* USG and not HAVE_SIGLIST. */ #endif
#if defined(USG) && !defined(USGr3) && !defined(HAVE_DUP2) #ifdef DUP2_MISSING
int int
dup2 (old, new) dup2 (old, new)
int old, new; int old, new;
@ -1371,4 +1359,4 @@ dup2 (old, new)
return fd; return fd;
} }
#endif /* USG and not USGr3 and not HAVE_DUP2. */ #endif