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 ksh_wait.h that reinvents <sys/wait.h> (PO...
details: https://anonhg.NetBSD.org/src/rev/8440922ac076
branches: trunk
changeset: 354788:8440922ac076
user: kamil <kamil%NetBSD.org@localhost>
date: Fri Jun 30 01:52:34 2017 +0000
description:
ksh: Drop ksh_wait.h that reinvents <sys/wait.h> (POSIX header)
Switch jobs.c to <sys/wait.h>.
No functional change intended.
diffstat:
bin/ksh/jobs.c | 25 ++++++++++++-------------
bin/ksh/ksh_wait.h | 52 ----------------------------------------------------
2 files changed, 12 insertions(+), 65 deletions(-)
diffs (163 lines):
diff -r bb07a9a13978 -r 8440922ac076 bin/ksh/jobs.c
--- a/bin/ksh/jobs.c Fri Jun 30 01:36:30 2017 +0000
+++ b/bin/ksh/jobs.c Fri Jun 30 01:52:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: jobs.c,v 1.14 2017/06/23 00:29:42 kamil Exp $ */
+/* $NetBSD: jobs.c,v 1.15 2017/06/30 01:52:34 kamil Exp $ */
/*
* Process and job control
@@ -26,13 +26,13 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: jobs.c,v 1.14 2017/06/23 00:29:42 kamil Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.15 2017/06/30 01:52:34 kamil Exp $");
#endif
+#include <sys/wait.h>
#include "sh.h"
#include "ksh_stat.h"
-#include "ksh_wait.h"
#include "ksh_times.h"
#include "tty.h"
@@ -103,7 +103,7 @@
struct proc {
Proc *next; /* next process in pipeline (if any) */
int state;
- WAIT_T status; /* wait status */
+ int status; /* wait status */
pid_t pid; /* process id */
char command[48]; /* process command string */
};
@@ -469,7 +469,7 @@
p = new_proc();
p->next = (Proc *) 0;
p->state = PRUNNING;
- WSTATUS(p->status) = 0;
+ p->status = 0;
p->pid = 0;
/* link process into jobs list */
@@ -891,7 +891,7 @@
for (p = j->proc_list; p != (Proc *) 0; p = p->next) {
if (p->state == PSTOPPED) {
p->state = PRUNNING;
- WSTATUS(p->status) = 0;
+ p->status = 0;
running = 1;
}
shprintf("%s%s", p->command, p->next ? "| " : null);
@@ -1212,7 +1212,7 @@
j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY);
if (j->flags & JF_FG) {
- WAIT_T status;
+ int status;
j->flags &= ~JF_FG;
#ifdef TTY_PGRP
@@ -1317,7 +1317,7 @@
Job *j;
Proc UNINITIALIZED(*p);
int pid;
- WAIT_T status;
+ int status;
struct tms t0, t1;
#ifdef JOB_SIGS
@@ -1336,7 +1336,7 @@
ksh_times(&t0);
do {
#ifdef JOB_SIGS
- pid = ksh_waitpid(-1, &status, (WNOHANG|WUNTRACED));
+ pid = waitpid(-1, &status, (WNOHANG|WUNTRACED));
#else /* JOB_SIGS */
pid = wait(&status);
#endif /* JOB_SIGS */
@@ -1513,7 +1513,7 @@
{
Proc *p;
int state;
- WAIT_T status;
+ int status;
int coredumped;
char jobchar = ' ';
char buf[64];
@@ -1556,7 +1556,7 @@
WEXITSTATUS(p->status));
break;
case PSIGNALLED:
- if (WIFCORED(p->status))
+ if (WCOREDUMP(p->status))
coredumped = 1;
/* kludge for not reporting `normal termination signals'
* (ie, SIGINT, SIGPIPE)
@@ -1597,8 +1597,7 @@
state = p->state;
status = p->status;
p = p->next;
- while (p && p->state == state
- && WSTATUS(p->status) == WSTATUS(status))
+ while (p && p->state == state && p->status == status)
{
if (how == JP_LONG)
shf_fprintf(shf, "%s%5d %-20s %s%s", filler, p->pid,
diff -r bb07a9a13978 -r 8440922ac076 bin/ksh/ksh_wait.h
--- a/bin/ksh/ksh_wait.h Fri Jun 30 01:36:30 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/* $NetBSD: ksh_wait.h,v 1.2 1997/01/12 19:12:03 tls Exp $ */
-
-/* Wrapper around the ugly sys/wait includes/ifdefs */
-/* $NetBSD: ksh_wait.h,v 1.2 1997/01/12 19:12:03 tls Exp $ */
-
-#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-
-#ifndef POSIX_SYS_WAIT
-/* Get rid of system macros (which probably use union wait) */
-# undef WIFCORED
-# undef WIFEXITED
-# undef WEXITSTATUS
-# undef WIFSIGNALED
-# undef WTERMSIG
-# undef WIFSTOPPED
-# undef WSTOPSIG
-#endif /* POSIX_SYS_WAIT */
-
-typedef int WAIT_T;
-
-#ifndef WIFCORED
-# define WIFCORED(s) ((s) & 0x80)
-#endif
-#define WSTATUS(s) (s)
-
-#ifndef WIFEXITED
-# define WIFEXITED(s) (((s) & 0xff) == 0)
-#endif
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(s) (((s) >> 8) & 0xff)
-#endif
-#ifndef WIFSIGNALED
-# define WIFSIGNALED(s) (((s) & 0xff) != 0 && ((s) & 0xff) != 0x7f)
-#endif
-#ifndef WTERMSIG
-# define WTERMSIG(s) ((s) & 0x7f)
-#endif
-#ifndef WIFSTOPPED
-# define WIFSTOPPED(s) (((s) & 0xff) == 0x7f)
-#endif
-#ifndef WSTOPSIG
-# define WSTOPSIG(s) (((s) >> 8) & 0xff)
-#endif
-
-#if !defined(HAVE_WAITPID) && defined(HAVE_WAIT3)
- /* always used with p == -1 */
-# define ksh_waitpid(p, s, o) wait3((s), (o), (struct rusage *) 0)
-#else /* !HAVE_WAITPID && HAVE_WAIT3 */
-# define ksh_waitpid(p, s, o) waitpid((p), (s), (o))
-#endif /* !HAVE_WAITPID && HAVE_WAIT3 */
Home |
Main Index |
Thread Index |
Old Index