Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ksh ksh: Drop support for systems without functional wai...



details:   https://anonhg.NetBSD.org/src/rev/15bfec188c49
branches:  trunk
changeset: 825095:15bfec188c49
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri Jun 30 02:38:09 2017 +0000

description:
ksh: Drop support for systems without functional waitpid(2)

diffstat:

 bin/ksh/conf-end.h |  13 +-------
 bin/ksh/config.h   |   8 +----
 bin/ksh/exec.c     |  12 ++-----
 bin/ksh/jobs.c     |  82 +----------------------------------------------------
 bin/ksh/sh.h       |   6 +--
 5 files changed, 11 insertions(+), 110 deletions(-)

diffs (truncated from 500 to 300 lines):

diff -r 44de817863d8 -r 15bfec188c49 bin/ksh/conf-end.h
--- a/bin/ksh/conf-end.h        Fri Jun 30 02:20:47 2017 +0000
+++ b/bin/ksh/conf-end.h        Fri Jun 30 02:38:09 2017 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: conf-end.h,v 1.6 2017/06/30 02:20:47 kamil Exp $       */
+/*     $NetBSD: conf-end.h,v 1.7 2017/06/30 02:38:09 kamil Exp $       */
 
 /*
  * End of configuration stuff for PD ksh.
  *
- * RCSid: $NetBSD: conf-end.h,v 1.6 2017/06/30 02:20:47 kamil Exp $
+ * RCSid: $NetBSD: conf-end.h,v 1.7 2017/06/30 02:38:09 kamil Exp $
  */
 
 #if defined(EMACS) || defined(VI)
@@ -22,15 +22,6 @@
 # define EASY_HISTORY                  /* sjg's trivial history file */
 #endif
 
-/* Can we safely catch sigchld and wait for processes? */
-#if defined(HAVE_WAITPID) || defined(HAVE_WAIT3)
-# define JOB_SIGS
-#endif
-
-#if !defined(JOB_SIGS) || !(defined(POSIX_PGRP) || defined(BSD_PGRP))
-# undef JOBS /* if no JOB_SIGS, no job control support */
-#endif
-
 #ifdef HAVE_GCC_FUNC_ATTR
 # define GCC_FUNC_ATTR(x)      __attribute__((x))
 # define GCC_FUNC_ATTR2(x,y)   __attribute__((x,y))
diff -r 44de817863d8 -r 15bfec188c49 bin/ksh/config.h
--- a/bin/ksh/config.h  Fri Jun 30 02:20:47 2017 +0000
+++ b/bin/ksh/config.h  Fri Jun 30 02:38:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config.h,v 1.44 2017/06/30 02:20:47 kamil Exp $        */
+/*     $NetBSD: config.h,v 1.45 2017/06/30 02:38:09 kamil Exp $        */
 
 /* config.h.  Generated automatically by configure.  */
 /* config.h.in.  Generated automatically from configure.in by autoheader.  */
@@ -187,12 +187,6 @@
 /* Define if you have the valloc function.  */
 #define HAVE_VALLOC 1
 
-/* Define if you have the wait3 function.  */
-#define HAVE_WAIT3 1
-
-/* Define if you have the waitpid function.  */
-#define HAVE_WAITPID 1
-
 /* Define if you have the <dirent.h> header file.  */
 #define HAVE_DIRENT_H 1
 
diff -r 44de817863d8 -r 15bfec188c49 bin/ksh/exec.c
--- a/bin/ksh/exec.c    Fri Jun 30 02:20:47 2017 +0000
+++ b/bin/ksh/exec.c    Fri Jun 30 02:38:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec.c,v 1.20 2017/06/30 02:06:59 kamil Exp $  */
+/*     $NetBSD: exec.c,v 1.21 2017/06/30 02:38:10 kamil Exp $  */
 
 /*
  * execute command tree
@@ -6,7 +6,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: exec.c,v 1.20 2017/06/30 02:06:59 kamil Exp $");
+__RCSID("$NetBSD: exec.c,v 1.21 2017/06/30 02:38:10 kamil Exp $");
 #endif
 
 
@@ -201,11 +201,8 @@
 #ifdef KSH
          case TCOPROC:
          {
-# ifdef JOB_SIGS
                sigset_t        omask;
-# endif /* JOB_SIGS */
 
-# ifdef JOB_SIGS
                /* Block sigchild as we are using things changed in the
                 * signal handler
                 */
@@ -218,7 +215,7 @@
                        unwind(i);
                        /*NOTREACHED*/
                }
-# endif /* JOB_SIGS */
+
                /* Already have a (live) co-process? */
                if (coproc.job && coproc.write >= 0)
                        errorf("coprocess already exists");
@@ -249,10 +246,9 @@
                        /* create new coprocess id */
                        ++coproc.id;
                }
-# ifdef JOB_SIGS
+
                sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
                e->type = E_EXEC; /* no more need for error handler */
-# endif /* JOB_SIGS */
 
                /* exchild() closes coproc.* in child after fork,
                 * will also increment coproc.njobs when the
diff -r 44de817863d8 -r 15bfec188c49 bin/ksh/jobs.c
--- a/bin/ksh/jobs.c    Fri Jun 30 02:20:47 2017 +0000
+++ b/bin/ksh/jobs.c    Fri Jun 30 02:38:09 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: jobs.c,v 1.15 2017/06/30 01:52:34 kamil Exp $  */
+/*     $NetBSD: jobs.c,v 1.16 2017/06/30 02:38:10 kamil Exp $  */
 
 /*
  * Process and job control
@@ -14,11 +14,6 @@
  * work :)
  *
  * Notes regarding the copious ifdefs:
- *     - JOB_SIGS is independent of JOBS - it is defined if there are modern
- *       signal and wait routines available.  This is preferred, even when
- *       JOBS is not defined, since the shell will not otherwise notice when
- *       background jobs die until the shell waits for a foreground process
- *       to die.
  *     - TTY_PGRP defined iff JOBS is defined - defined if there are tty
  *       process groups
  *     - NEED_PGRP_SYNC defined iff JOBS is defined - see comment below
@@ -26,7 +21,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: jobs.c,v 1.15 2017/06/30 01:52:34 kamil Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.16 2017/06/30 02:38:10 kamil Exp $");
 #endif
 
 #include <sys/wait.h>
@@ -187,10 +182,8 @@
 static int             child_max;      /* CHILD_MAX */
 
 
-#ifdef JOB_SIGS
 /* held_sigchld is set if sigchld occurs before a job is completely started */
 static int             held_sigchld;
-#endif /* JOB_SIGS */
 
 #ifdef JOBS
 static struct shf      *shl_j;
@@ -236,7 +229,6 @@
 {
        child_max = CHILD_MAX; /* so syscon() isn't always being called */
 
-#ifdef JOB_SIGS
        sigemptyset(&sm_default);
        sigprocmask(SIG_SETMASK, &sm_default, (sigset_t *) 0);
 
@@ -245,10 +237,6 @@
 
        setsig(&sigtraps[SIGCHLD], j_sigchld,
                SS_RESTORE_ORIG|SS_FORCE|SS_SHTRAP);
-#else /* JOB_SIGS */
-       /* Make sure SIGCHLD isn't ignored - can do odd things under SYSV */
-       setsig(&sigtraps[SIGCHLD], SIG_DFL, SS_RESTORE_ORIG|SS_FORCE);
-#endif /* JOB_SIGS */
 
 #ifdef JOBS
        if (!mflagset && Flag(FTALKING))
@@ -446,9 +434,7 @@
        static Proc     *last_proc;     /* for pipelines */
 
        int             i;
-#ifdef JOB_SIGS
        sigset_t        omask;
-#endif /* JOB_SIGS */
        Proc            *p;
        Job             *j;
        int             rv = 0;
@@ -461,10 +447,8 @@
                 */
                return execute(t, flags & (XEXEC | XERROK));
 
-#ifdef JOB_SIGS
        /* no SIGCHLD's while messing with job and process lists */
        sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
-#endif /* JOB_SIGS */
 
        p = new_proc();
        p->next = (Proc *) 0;
@@ -530,9 +514,7 @@
                        j_sync_open = 0;
                }
 #endif /* NEED_PGRP_SYNC */
-#ifdef JOB_SIGS
                sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#endif /* JOB_SIGS */
                errorf("cannot fork - try again");
        }
        ischild = i == 0;
@@ -609,9 +591,7 @@
                if (flags & XCOPROC)
                        coproc_cleanup(FALSE);
 #endif /* KSH */
-#ifdef JOB_SIGS
                sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#endif /* JOB_SIGS */
                cleanup_parents_env();
 #ifdef TTY_PGRP
                /* If FMONITOR or FTALKING is set, these signals are ignored,
@@ -687,9 +667,7 @@
                        rv = j_waitj(j, JW_NONE, "jw:last proc");
        }
 
-#ifdef JOB_SIGS
        sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#endif /* JOB_SIGS */
 
        return rv;
 }
@@ -698,20 +676,16 @@
 void
 startlast()
 {
-#ifdef JOB_SIGS
        sigset_t omask;
 
        sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
-#endif /* JOB_SIGS */
 
        if (last_job) { /* no need to report error - waitlast() will do it */
                /* ensure it isn't removed by check_job() */
                last_job->flags |= JF_WAITING;
                j_startjob(last_job);
        }
-#ifdef JOB_SIGS
        sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#endif /* JOB_SIGS */
 }
 
 /* wait for last job: only used for `command` jobs */
@@ -720,11 +694,9 @@
 {
        int     rv;
        Job     *j;
-#ifdef JOB_SIGS
        sigset_t omask;
 
        sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
-#endif /* JOB_SIGS */
 
        j = last_job;
        if (!j || !(j->flags & JF_STARTED)) {
@@ -732,17 +704,13 @@
                        warningf(TRUE, "waitlast: no last job");
                else
                        internal_errorf(0, "waitlast: not started");
-#ifdef JOB_SIGS
                sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#endif /* JOB_SIGS */
                return 125; /* not so arbitrary, non-zero value */
        }
 
        rv = j_waitj(j, JW_NONE, "jw:waitlast");
 
-#ifdef JOB_SIGS
        sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#endif /* JOB_SIGS */
 
        return rv;
 }
@@ -757,11 +725,9 @@
        Job     *j;
        int     ecode;
        int     flags = JW_INTERRUPT|JW_ASYNCNOTIFY;
-#ifdef JOB_SIGS
        sigset_t omask;
 
        sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
-#endif /* JOB_SIGS */
 
        *sigp = 0;
 
@@ -774,24 +740,18 @@
                        if (j->ppid == procpid && j->state == PRUNNING)
                                break;
                if (!j) {
-#ifdef JOB_SIGS
                        sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#endif /* JOB_SIGS */
                        return -1;
                }
        } else if ((j = j_lookup(cp, &ecode))) {
                /* don't report normal job completion */
                flags &= ~JW_ASYNCNOTIFY;
                if (j->ppid != procpid) {
-#ifdef JOB_SIGS
                        sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#endif /* JOB_SIGS */
                        return -1;
                }
        } else {
-#ifdef JOB_SIGS
                sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
-#endif /* JOB_SIGS */



Home | Main Index | Thread Index | Old Index