projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
date and time created 91/03/07 20:28:05 by bostic
[unix-history]
/
usr
/
src
/
bin
/
csh
/
proc.c
diff --git
a/usr/src/bin/csh/proc.c
b/usr/src/bin/csh/proc.c
index
85a2312
..
bd36abd
100644
(file)
--- a/
usr/src/bin/csh/proc.c
+++ b/
usr/src/bin/csh/proc.c
@@
-1,16
+1,17
@@
/*
* Copyright (c) 1980 Regents of the University of California.
/*
* Copyright (c) 1980 Regents of the University of California.
- * All rights reserved. The Berkeley
s
oftware License Agreement
+ * All rights reserved. The Berkeley
S
oftware License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
-static char
sccsid[] = "@(#)proc.c 5.1
(Berkeley) %G%";
-#endif
not lint
+static char
*sccsid = "@(#)proc.c 5.13
(Berkeley) %G%";
+#endif
#include "sh.h"
#include "sh.dir.h"
#include "sh.proc.h"
#include "sh.h"
#include "sh.dir.h"
#include "sh.proc.h"
+#include <string.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
@@
-27,6
+28,7
@@
static char sccsid[] = "@(#)proc.c 5.1 (Berkeley) %G%";
* childs status. Top level routines (like pwait) must be sure
* to mask interrupts when playing with the proclist data structures!
*/
* childs status. Top level routines (like pwait) must be sure
* to mask interrupts when playing with the proclist data structures!
*/
+void
pchild()
{
register struct process *pp;
pchild()
{
register struct process *pp;
@@
-35,9
+37,11
@@
pchild()
union wait w;
int jobflags;
struct rusage ru;
union wait w;
int jobflags;
struct rusage ru;
+ extern int insource;
loop:
loop:
- pid = wait3(&w, (setintr ? WNOHANG|WUNTRACED:WNOHANG), &ru);
+ pid = wait3((int *)&w,
+ (setintr && (intty || insource) ? WNOHANG|WUNTRACED:WNOHANG), &ru);
if (pid <= 0) {
if (errno == EINTR) {
errno = 0;
if (pid <= 0) {
if (errno == EINTR) {
errno = 0;
@@
-108,9
+112,6
@@
found:
pclrcurr(fp);
if (jobflags&PFOREGND) {
if (jobflags & (PSIGNALED|PSTOPPED|PPTIME) ||
pclrcurr(fp);
if (jobflags&PFOREGND) {
if (jobflags & (PSIGNALED|PSTOPPED|PPTIME) ||
-#ifdef IIASA
- jobflags & PAEXITED ||
-#endif
!eq(dcwd->di_name, fp->p_cwd->di_name)) {
; /* print in pjwait */
}
!eq(dcwd->di_name, fp->p_cwd->di_name)) {
; /* print in pjwait */
}
@@
-136,7
+137,8
@@
found:
pnote()
{
register struct process *pp;
pnote()
{
register struct process *pp;
- int flags, omask;
+ int flags;
+ long omask;
neednote = 0;
for (pp = proclist.p_next; pp != PNULL; pp = pp->p_next) {
neednote = 0;
for (pp = proclist.p_next; pp != PNULL; pp = pp->p_next) {
@@
-158,7
+160,7
@@
pnote()
pwait()
{
register struct process *fp, *pp;
pwait()
{
register struct process *fp, *pp;
-
int
omask;
+
long
omask;
/*
* Here's where dead procs get flushed.
/*
* Here's where dead procs get flushed.
@@
-186,7
+188,8
@@
pjwait(pp)
register struct process *pp;
{
register struct process *fp;
register struct process *pp;
{
register struct process *fp;
- int jobflags, reason, omask;
+ int jobflags, reason;
+ long omask;
while (pp->p_pid != pp->p_jobid)
pp = pp->p_friends;
while (pp->p_pid != pp->p_jobid)
pp = pp->p_friends;
@@
-208,7
+211,7
@@
pjwait(pp)
while ((fp = (fp->p_friends)) != pp);
if ((jobflags & PRUNNING) == 0)
break;
while ((fp = (fp->p_friends)) != pp);
if ((jobflags & PRUNNING) == 0)
break;
- sigpause(
0
);
+ sigpause(
sigblock(0L) &~ sigmask(SIGCHLD)
);
}
(void) sigsetmask(omask);
if (tpgrp > 0) /* get tty back */
}
(void) sigsetmask(omask);
if (tpgrp > 0) /* get tty back */
@@
-245,7
+248,7
@@
pjwait(pp)
dowait()
{
register struct process *pp;
dowait()
{
register struct process *pp;
-
int
omask;
+
long
omask;
pjobs++;
omask = sigblock(sigmask(SIGCHLD));
pjobs++;
omask = sigblock(sigmask(SIGCHLD));
@@
-253,7
+256,7
@@
loop:
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_pid && /* pp->p_pid == pp->p_jobid && */
pp->p_flags&PRUNNING) {
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_pid && /* pp->p_pid == pp->p_jobid && */
pp->p_flags&PRUNNING) {
- sigpause(0);
+ sigpause(0
L
);
goto loop;
}
(void) sigsetmask(omask);
goto loop;
}
(void) sigsetmask(omask);
@@
-563,7
+566,7
@@
pprint(pp, flag)
printf("%5d ", pp->p_pid);
if (flag&(REASON|AREASON)) {
if (flag&NAME)
printf("%5d ", pp->p_pid);
if (flag&(REASON|AREASON)) {
if (flag&NAME)
- format = "%-2
1
s";
+ format = "%-2
3
s";
else
format = "%s";
if (pstatus == status)
else
format = "%s";
if (pstatus == status)
@@
-585,8
+588,9
@@
pprint(pp, flag)
case PINTERRUPTED:
case PSTOPPED:
case PSIGNALED:
case PINTERRUPTED:
case PSTOPPED:
case PSIGNALED:
- if (flag&REASON || reason != SIGINT ||
- reason != SIGPIPE)
+ if ((flag&(REASON|AREASON))
+ && reason != SIGINT
+ && reason != SIGPIPE)
printf(format, mesg[pp->p_reason].pname);
break;
printf(format, mesg[pp->p_reason].pname);
break;
@@
-782,14
+786,14
@@
dokill(v)
if (name = mesg[signum].iname)
printf("%s ", name);
if (signum == 16)
if (name = mesg[signum].iname)
printf("%s ", name);
if (signum == 16)
- putchar('\n');
+
csh
putchar('\n');
}
}
- putchar('\n');
+
csh
putchar('\n');
return;
}
if (digit(v[0][1])) {
signum = atoi(v[0]+1);
return;
}
if (digit(v[0][1])) {
signum = atoi(v[0]+1);
- if (signum <
1
|| signum > NSIG)
+ if (signum <
0
|| signum > NSIG)
bferr("Bad signal number");
} else {
name = &v[0][1];
bferr("Bad signal number");
} else {
name = &v[0][1];
@@
-813,9
+817,9
@@
pkill(v, signum)
{
register struct process *pp, *np;
register int jobflags = 0;
{
register struct process *pp, *np;
register int jobflags = 0;
- int omask, pid, err = 0;
+ int pid, err = 0;
+ long omask;
char *cp;
char *cp;
- extern char *sys_errlist[];
omask = sigmask(SIGCHLD);
if (setintr)
omask = sigmask(SIGCHLD);
if (setintr)
@@
-835,25
+839,23
@@
pkill(v, signum)
case SIGTTIN:
case SIGTTOU:
if ((jobflags & PRUNNING) == 0) {
case SIGTTIN:
case SIGTTOU:
if ((jobflags & PRUNNING) == 0) {
- printf("%s: Already s
topp
ed\n", cp);
+ printf("%s: Already s
uspend
ed\n", cp);
err++;
goto cont;
}
}
if (killpg(pp->p_jobid, signum) < 0) {
err++;
goto cont;
}
}
if (killpg(pp->p_jobid, signum) < 0) {
- printf("%s: ", cp);
- printf("%s\n", sys_errlist[errno]);
+ printf("%s: %s\n", cp, strerror(errno));
err++;
}
if (signum == SIGTERM || signum == SIGHUP)
(void) killpg(pp->p_jobid, SIGCONT);
err++;
}
if (signum == SIGTERM || signum == SIGHUP)
(void) killpg(pp->p_jobid, SIGCONT);
- } else if (!
digit(*cp
))
+ } else if (!
(digit(*cp) || *cp == '-'
))
bferr("Arguments should be jobs or process id's");
else {
pid = atoi(cp);
if (kill(pid, signum) < 0) {
bferr("Arguments should be jobs or process id's");
else {
pid = atoi(cp);
if (kill(pid, signum) < 0) {
- printf("%d: ", pid);
- printf("%s\n", sys_errlist[errno]);
+ printf("%d: %s\n", pid, strerror(errno));
err++;
goto cont;
}
err++;
goto cont;
}
@@
-877,7
+879,8
@@
pstart(pp, foregnd)
int foregnd;
{
register struct process *np;
int foregnd;
{
register struct process *np;
- int omask, jobflags = 0;
+ int jobflags = 0;
+ long omask;
omask = sigblock(sigmask(SIGCHLD));
np = pp;
omask = sigblock(sigmask(SIGCHLD));
np = pp;
@@
-909,7
+912,7
@@
panystop(neednl)
chkstop = 2;
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_flags & PSTOPPED)
chkstop = 2;
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_flags & PSTOPPED)
- error("\nThere are s
topp
ed jobs" + 1 - neednl);
+ error("\nThere are s
uspend
ed jobs" + 1 - neednl);
}
struct process *
}
struct process *
@@
-1012,7
+1015,8
@@
pfork(t, wanttty)
{
register int pid;
bool ignint = 0;
{
register int pid;
bool ignint = 0;
- int pgrp, omask;
+ int pgrp;
+ long omask;
/*
* A child will be uninterruptible only under very special
/*
* A child will be uninterruptible only under very special
@@
-1062,10
+1066,10
@@
pfork(t, wanttty)
(void) signal(SIGINT, SIG_IGN);
(void) signal(SIGQUIT, SIG_IGN);
}
(void) signal(SIGINT, SIG_IGN);
(void) signal(SIGQUIT, SIG_IGN);
}
- if (wanttty > 0)
- (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&pgrp);
if (wanttty >= 0 && tpgrp >= 0)
(void) setpgrp(0, pgrp);
if (wanttty >= 0 && tpgrp >= 0)
(void) setpgrp(0, pgrp);
+ if (wanttty > 0)
+ (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&pgrp);
if (tpgrp > 0)
tpgrp = 0; /* gave tty away */
/*
if (tpgrp > 0)
tpgrp = 0; /* gave tty away */
/*
@@
-1078,6
+1082,8
@@
pfork(t, wanttty)
if (t->t_dflg & FNICE)
(void) setpriority(PRIO_PROCESS, 0, t->t_nice);
} else {
if (t->t_dflg & FNICE)
(void) setpriority(PRIO_PROCESS, 0, t->t_nice);
} else {
+ if (wanttty >= 0 && tpgrp >= 0)
+ (void) setpgrp(pid, pcurrjob ? pcurrjob->p_jobid : pid);
palloc(pid, t);
(void) sigsetmask(omask);
}
palloc(pid, t);
(void) sigsetmask(omask);
}