ksh: Drop ksh_wait.h that reinvents <sys/wait.h> (POSIX header)
Switch jobs.c to <sys/wait.h>. No functional change intended.
This commit is contained in:
parent
d0aa393796
commit
3e63fce1f9
@ -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 @@ typedef struct proc Proc;
|
||||
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 @@ exchild(t, flags, close_fd)
|
||||
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 @@ j_resume(cp, bg)
|
||||
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_waitj(j, flags, where)
|
||||
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 @@ j_sigchld(sig)
|
||||
Job *j;
|
||||
Proc UNINITIALIZED(*p);
|
||||
int pid;
|
||||
WAIT_T status;
|
||||
int status;
|
||||
struct tms t0, t1;
|
||||
|
||||
#ifdef JOB_SIGS
|
||||
@ -1336,7 +1336,7 @@ j_sigchld(sig)
|
||||
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 @@ j_print(j, how, shf)
|
||||
{
|
||||
Proc *p;
|
||||
int state;
|
||||
WAIT_T status;
|
||||
int status;
|
||||
int coredumped;
|
||||
char jobchar = ' ';
|
||||
char buf[64];
|
||||
@ -1556,7 +1556,7 @@ j_print(j, how, shf)
|
||||
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 @@ j_print(j, how, shf)
|
||||
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,
|
||||
|
@ -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 */
|
Loading…
Reference in New Issue
Block a user