2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 4. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 static char sccsid
[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
38 #include <sys/cdefs.h>
40 __FBSDID("$FreeBSD: src/bin/sh/jobs.c,v 1.67 2004/04/06 20:06:51 markm Exp $");
45 #include <sys/types.h>
58 #include <sys/param.h>
61 #include <sys/resource.h>
63 #include <sys/ioctl.h>
67 #undef CEOF /* syntax.h redefines this */
86 /* #define NO_KILLPG */
90 #define _PATH_TTY "/dev/tty"
93 #define _PATH_DEVNULL "/dev/null"
96 STATIC
struct job
*jobtab
; /* array of jobs */
97 STATIC
int njobs
; /* size of array */
98 MKINIT pid_t backgndpid
= -1; /* pid of last background process */
100 STATIC
struct job
*jobmru
; /* most recently used job list */
101 STATIC pid_t initialpgrp
; /* pgrp of shell on invocation */
103 int in_waitcmd
= 0; /* are we in waitcmd()? */
104 int in_dowait
= 0; /* are we in dowait()? */
105 volatile sig_atomic_t breakwaitcmd
= 0; /* should wait be terminated? */
107 static int ttyfd
= -1;
111 #define WCOREDUMP(s) ((s) & 0x80)
115 STATIC
void restartjob(struct job
*);
117 STATIC
void freejob(struct job
*);
118 STATIC
struct job
*getjob(char *);
119 STATIC pid_t
dowait(int, struct job
*);
120 STATIC pid_t
waitproc(int, int *);
121 STATIC
void cmdtxt(union node
*);
122 STATIC
void cmdputs(char *);
124 STATIC
void setcurjob(struct job
*);
125 STATIC
void deljob(struct job
*);
126 STATIC
struct job
*getcurjob(struct job
*);
128 STATIC
void showjob(struct job
*, pid_t
, int, int);
131 static int killpg(pid_t
,int);
135 * Turn job control on and off.
146 if (on
== jobctl
|| rootshell
== 0)
151 if ((ttyfd
= open(_PATH_TTY
, O_RDWR
)) < 0) {
153 while (i
<= 2 && !isatty(i
))
155 if (i
> 2 || (ttyfd
= fcntl(i
, F_DUPFD
, 10)) < 0)
160 * Keep our TTY file descriptor out of the way of
161 * the user's redirections.
163 if ((i
= fcntl(ttyfd
, F_DUPFD
, 10)) < 0) {
171 if (fcntl(ttyfd
, F_SETFD
, FD_CLOEXEC
) < 0) {
176 do { /* while we are in the background */
177 initialpgrp
= tcgetpgrp(ttyfd
);
178 if (initialpgrp
< 0) {
179 out
: out2str("sh: can't access tty; job control turned off\n");
183 if (initialpgrp
== -1)
184 initialpgrp
= getpgrp();
185 else if (initialpgrp
!= getpgrp()) {
194 tcsetpgrp(ttyfd
, rootpid
);
195 } else { /* turning job control off */
196 setpgid(0, initialpgrp
);
197 tcsetpgrp(ttyfd
, initialpgrp
);
210 INCLUDE
<sys
/types
.h
>
226 fgcmd(int argc __unused
, char **argv
)
232 jp
= getjob(argv
[1]);
234 error("job not created under job control");
235 out1str(jp
->ps
[0].cmd
);
238 pgrp
= jp
->ps
[0].pid
;
239 tcsetpgrp(ttyfd
, pgrp
);
243 status
= waitforjob(jp
, (int *)NULL
);
250 bgcmd(int argc
, char **argv
)
256 jp
= getjob(*++argv
);
258 error("job not created under job control");
259 if (jp
->state
== JOBDONE
)
263 fmtstr(s
, 64, "[%td] ", jp
- jobtab
+ 1);
265 out1str(jp
->ps
[0].cmd
);
267 } while (--argc
> 1);
273 restartjob(struct job
*jp
)
278 if (jp
->state
== JOBDONE
)
282 killpg(jp
->ps
[0].pid
, SIGCONT
);
283 for (ps
= jp
->ps
, i
= jp
->nprocs
; --i
>= 0 ; ps
++) {
284 if (WIFSTOPPED(ps
->status
)) {
295 jobscmd(int argc
, char *argv
[])
298 int ch
, sformat
, lformat
;
300 optind
= optreset
= 1;
302 sformat
= lformat
= 0;
303 while ((ch
= getopt(argc
, argv
, "ls")) != -1) {
313 error("unknown option: -%c", optopt
);
320 showjobs(0, sformat
, lformat
);
322 while ((id
= *argv
++) != NULL
)
323 showjob(getjob(id
), 0, sformat
, lformat
);
329 showjob(struct job
*jp
, pid_t pid
, int sformat
, int lformat
)
336 int col
, curr
, i
, jobno
, prev
, procno
;
340 jobno
= jp
- jobtab
+ 1;
343 if ((j
= getcurjob(NULL
)) != NULL
) {
344 curr
= j
- jobtab
+ 1;
345 if ((j
= getcurjob(j
)) != NULL
)
346 prev
= j
- jobtab
+ 1;
349 for (ps
= jp
->ps
; ; ps
++) { /* for each process */
351 out1fmt("%d\n", (int)ps
->pid
);
354 if (!lformat
&& ps
!= jp
->ps
&& pid
== 0)
356 if (pid
!= 0 && pid
!= ps
->pid
)
358 if (jobno
== curr
&& ps
== jp
->ps
)
360 else if (jobno
== prev
&& ps
== jp
->ps
)
365 fmtstr(s
, 64, "[%d] %c ", jobno
, c
);
367 fmtstr(s
, 64, " %c ", c
);
371 fmtstr(s
, 64, "%d ", (int)ps
->pid
);
378 } else if (ps
->status
== -1) {
379 strcpy(s
, "Running");
380 } else if (WIFEXITED(ps
->status
)) {
381 if (WEXITSTATUS(ps
->status
) == 0)
384 fmtstr(s
, 64, "Done (%d)",
385 WEXITSTATUS(ps
->status
));
388 if (WIFSTOPPED(ps
->status
))
389 i
= WSTOPSIG(ps
->status
);
392 i
= WTERMSIG(ps
->status
);
393 if ((i
& 0x7F) < _NSIG
&& strsiglist(i
& 0x7F))
394 scopy(strsiglist(i
& 0x7F), s
);
396 fmtstr(s
, 64, "Signal %d", i
& 0x7F);
397 if (WCOREDUMP(ps
->status
))
398 strcat(s
, " (core dumped)");
408 skip
: if (--procno
<= 0)
414 * Print a list of jobs. If "change" is nonzero, only print jobs whose
415 * statuses have changed since the last call to showjobs.
417 * If the shell is interrupted in the process of creating a job, the
418 * result may be a job structure containing zero processes. Such structures
419 * will be freed here.
423 showjobs(int change
, int sformat
, int lformat
)
428 TRACE(("showjobs(%d) called\n", change
));
429 while (dowait(0, (struct job
*)NULL
) > 0);
430 for (jobno
= 1, jp
= jobtab
; jobno
<= njobs
; jobno
++, jp
++) {
433 if (jp
->nprocs
== 0) {
437 if (change
&& ! jp
->changed
)
439 showjob(jp
, 0, sformat
, lformat
);
441 if (jp
->state
== JOBDONE
) {
449 * Mark a job structure as unused.
453 freejob(struct job
*jp
)
459 for (i
= jp
->nprocs
, ps
= jp
->ps
; --i
>= 0 ; ps
++) {
460 if (ps
->cmd
!= nullstr
)
463 if (jp
->ps
!= &jp
->ps0
)
475 waitcmd(int argc
, char **argv
)
482 job
= getjob(argv
[1]);
488 * Loop until a process is terminated or stopped, or a SIGINT is
496 status
= job
->ps
[job
->nprocs
- 1].status
;
497 if (WIFEXITED(status
))
498 retval
= WEXITSTATUS(status
);
500 else if (WIFSTOPPED(status
))
501 retval
= WSTOPSIG(status
) + 128;
504 retval
= WTERMSIG(status
) + 128;
511 for (jp
= jobtab
; ; jp
++) {
512 if (jp
>= jobtab
+ njobs
) { /* no running procs */
516 if (jp
->used
&& jp
->state
== 0)
520 } while (dowait(1, (struct job
*)NULL
) != -1);
529 jobidcmd(int argc __unused
, char **argv
)
534 jp
= getjob(argv
[1]);
535 for (i
= 0 ; i
< jp
->nprocs
; ) {
536 out1fmt("%d", (int)jp
->ps
[i
].pid
);
537 out1c(++i
< jp
->nprocs
? ' ' : '\n');
545 * Convert a job name to a job structure.
552 struct job
*found
, *jp
;
558 currentjob
: if ((jp
= getcurjob(NULL
)) == NULL
)
559 error("No current job");
562 error("No current job");
564 } else if (name
[0] == '%') {
565 if (is_digit(name
[1])) {
566 jobno
= number(name
+ 1);
567 if (jobno
> 0 && jobno
<= njobs
568 && jobtab
[jobno
- 1].used
!= 0)
569 return &jobtab
[jobno
- 1];
571 } else if (name
[1] == '%' && name
[2] == '\0') {
573 } else if (name
[1] == '+' && name
[2] == '\0') {
575 } else if (name
[1] == '-' && name
[2] == '\0') {
576 if ((jp
= getcurjob(NULL
)) == NULL
||
577 (jp
= getcurjob(jp
)) == NULL
)
578 error("No previous job");
581 } else if (name
[1] == '?') {
583 for (jp
= jobtab
, i
= njobs
; --i
>= 0 ; jp
++) {
584 if (jp
->used
&& jp
->nprocs
> 0
585 && strstr(jp
->ps
[0].cmd
, name
+ 2) != NULL
) {
587 error("%s: ambiguous", name
);
595 for (jp
= jobtab
, i
= njobs
; --i
>= 0 ; jp
++) {
596 if (jp
->used
&& jp
->nprocs
> 0
597 && prefix(name
+ 1, jp
->ps
[0].cmd
)) {
599 error("%s: ambiguous", name
);
606 } else if (is_number(name
)) {
607 pid
= (pid_t
)number(name
);
608 for (jp
= jobtab
, i
= njobs
; --i
>= 0 ; jp
++) {
609 if (jp
->used
&& jp
->nprocs
> 0
610 && jp
->ps
[jp
->nprocs
- 1].pid
== pid
)
614 error("No such job: %s", name
);
622 * Return a new job structure,
626 makejob(union node
*node __unused
, int nprocs
)
631 for (i
= njobs
, jp
= jobtab
; ; jp
++) {
635 jobtab
= ckmalloc(4 * sizeof jobtab
[0]);
640 jp
= ckmalloc((njobs
+ 4) * sizeof jobtab
[0]);
641 memcpy(jp
, jobtab
, njobs
* sizeof jp
[0]);
643 /* Relocate `next' pointers and list head */
645 jobmru
= &jp
[jobmru
- jobtab
];
646 for (i
= 0; i
< njobs
; i
++)
647 if (jp
[i
].next
!= NULL
)
648 jp
[i
].next
= &jp
[jp
[i
].next
-
651 /* Relocate `ps' pointers */
652 for (i
= 0; i
< njobs
; i
++)
653 if (jp
[i
].ps
== &jobtab
[i
].ps0
)
654 jp
[i
].ps
= &jp
[i
].ps0
;
659 for (i
= 4 ; --i
>= 0 ; jobtab
[njobs
++].used
= 0);
677 jp
->ps
= ckmalloc(nprocs
* sizeof (struct procstat
));
682 TRACE(("makejob(0x%lx, %d) returns %%%d\n", (long)node
, nprocs
,
689 setcurjob(struct job
*cj
)
691 struct job
*jp
, *prev
;
693 for (prev
= NULL
, jp
= jobmru
; jp
!= NULL
; prev
= jp
, jp
= jp
->next
) {
696 prev
->next
= jp
->next
;
709 deljob(struct job
*j
)
711 struct job
*jp
, *prev
;
713 for (prev
= NULL
, jp
= jobmru
; jp
!= NULL
; prev
= jp
, jp
= jp
->next
) {
716 prev
->next
= jp
->next
;
725 * Return the most recently used job that isn't `nj', and preferably one
729 getcurjob(struct job
*nj
)
733 /* Try to find a stopped one.. */
734 for (jp
= jobmru
; jp
!= NULL
; jp
= jp
->next
)
735 if (jp
->used
&& jp
!= nj
&& jp
->state
== JOBSTOPPED
)
737 /* Otherwise the most recently used job that isn't `nj' */
738 for (jp
= jobmru
; jp
!= NULL
; jp
= jp
->next
)
739 if (jp
->used
&& jp
!= nj
)
748 * Fork of a subshell. If we are doing job control, give the subshell its
749 * own process group. Jp is a job structure that the job is to be added to.
750 * N is the command that will be evaluated by the child. Both jp and n may
751 * be NULL. The mode parameter can be one of the following:
752 * FORK_FG - Fork off a foreground process.
753 * FORK_BG - Fork off a background process.
754 * FORK_NOJOB - Like FORK_FG, but don't give the process its own
755 * process group even if job control is on.
757 * When job control is turned off, background processes have their standard
758 * input redirected to /dev/null (except for the second and later processes
763 forkshell(struct job
*jp
, union node
*n
, int mode
)
768 TRACE(("forkshell(%%%d, 0x%lx, %d) called\n", jp
- jobtab
, (long)n
,
774 TRACE(("Fork failed, errno=%d\n", errno
));
776 error("Cannot fork: %s", strerror(errno
));
783 TRACE(("Child shell %d\n", (int)getpid()));
790 jobctl
= 0; /* do job control only in root shell */
791 if (wasroot
&& mode
!= FORK_NOJOB
&& mflag
) {
792 if (jp
== NULL
|| jp
->nprocs
== 0)
795 pgrp
= jp
->ps
[0].pid
;
796 if (setpgid(0, pgrp
) == 0 && mode
== FORK_FG
) {
797 /*** this causes superfluous TIOCSPGRPS ***/
798 if (tcsetpgrp(ttyfd
, pgrp
) < 0)
799 error("tcsetpgrp failed, errno=%d", errno
);
803 } else if (mode
== FORK_BG
) {
806 if ((jp
== NULL
|| jp
->nprocs
== 0) &&
807 ! fd0_redirected_p ()) {
809 if (open(_PATH_DEVNULL
, O_RDONLY
) != 0)
810 error("Can't open %s: %s",
811 _PATH_DEVNULL
, strerror(errno
));
815 if (mode
== FORK_BG
) {
818 if ((jp
== NULL
|| jp
->nprocs
== 0) &&
819 ! fd0_redirected_p ()) {
821 if (open(_PATH_DEVNULL
, O_RDONLY
) != 0)
822 error("Can't open %s: %s",
823 _PATH_DEVNULL
, strerror(errno
));
828 for (i
= njobs
, p
= jobtab
; --i
>= 0 ; p
++)
832 if (wasroot
&& iflag
) {
839 if (rootshell
&& mode
!= FORK_NOJOB
&& mflag
) {
840 if (jp
== NULL
|| jp
->nprocs
== 0)
843 pgrp
= jp
->ps
[0].pid
;
849 backgndpid
= pid
; /* set $! */
851 struct procstat
*ps
= &jp
->ps
[jp
->nprocs
++];
855 if (iflag
&& rootshell
&& n
)
856 ps
->cmd
= commandtext(n
);
857 jp
->foreground
= mode
== FORK_FG
;
863 TRACE(("In parent shell: child = %d\n", (int)pid
));
870 * Wait for job to finish.
872 * Under job control we have the problem that while a child process is
873 * running interrupts generated by the user are sent to the child but not
874 * to the shell. This means that an infinite loop started by an inter-
875 * active user may be hard to kill. With job control turned off, an
876 * interactive user may place an interactive program inside a loop. If
877 * the interactive program catches interrupts, the user doesn't want
878 * these interrupts to also abort the loop. The approach we take here
879 * is to have the shell ignore interrupt signals while waiting for a
880 * foreground process to terminate, and then send itself an interrupt
881 * signal if the child process was terminated by an interrupt signal.
882 * Unfortunately, some programs want to do a bit of cleanup and then
883 * exit on interrupt; unless these processes terminate themselves by
884 * sending a signal to themselves (instead of calling exit) they will
885 * confuse this approach.
889 waitforjob(struct job
*jp
, int *origstatus
)
892 pid_t mypgrp
= getpgrp();
898 TRACE(("waitforjob(%%%d) called\n", jp
- jobtab
+ 1));
899 while (jp
->state
== 0)
900 if (dowait(1, jp
) == -1)
904 if (tcsetpgrp(ttyfd
, mypgrp
) < 0)
905 error("tcsetpgrp failed, errno=%d\n", errno
);
907 if (jp
->state
== JOBSTOPPED
)
910 status
= jp
->ps
[jp
->nprocs
- 1].status
;
911 if (origstatus
!= NULL
)
912 *origstatus
= status
;
913 /* convert to 8 bits */
914 if (WIFEXITED(status
))
915 st
= WEXITSTATUS(status
);
917 else if (WIFSTOPPED(status
))
918 st
= WSTOPSIG(status
) + 128;
921 st
= WTERMSIG(status
) + 128;
922 if (! JOBS
|| jp
->state
== JOBDONE
)
925 if (WIFSIGNALED(status
) && WTERMSIG(status
) == SIGINT
)
926 kill(getpid(), SIGINT
);
937 * Wait for a process to terminate.
941 dowait(int block
, struct job
*job
)
954 TRACE(("dowait(%d) called\n", block
));
956 pid
= waitproc(block
, &status
);
957 TRACE(("wait returns %d, status=%d\n", (int)pid
, status
));
958 } while ((pid
== -1 && errno
== EINTR
&& breakwaitcmd
== 0) ||
959 (pid
> 0 && WIFSTOPPED(status
) && !iflag
));
961 if (breakwaitcmd
!= 0) {
969 for (jp
= jobtab
; jp
< jobtab
+ njobs
; jp
++) {
973 for (sp
= jp
->ps
; sp
< jp
->ps
+ jp
->nprocs
; sp
++) {
976 if (sp
->pid
== pid
) {
977 TRACE(("Changing status of proc %d from 0x%x to 0x%x\n",
978 (int)pid
, sp
->status
,
983 if (sp
->status
== -1)
985 else if (WIFSTOPPED(sp
->status
))
988 if (stopped
) { /* stopped or done */
989 int state
= done
? JOBDONE
: JOBSTOPPED
;
990 if (jp
->state
!= state
) {
991 TRACE(("Job %d: changing state from %d to %d\n", jp
- jobtab
+ 1, jp
->state
, state
));
1002 if (! rootshell
|| ! iflag
|| (job
&& thisjob
== job
)) {
1003 core
= WCOREDUMP(status
);
1005 if (WIFSTOPPED(status
))
1006 sig
= WSTOPSIG(status
);
1010 if (WIFEXITED(status
))
1013 sig
= WTERMSIG(status
);
1015 if (sig
!= 0 && sig
!= SIGINT
&& sig
!= SIGPIPE
) {
1017 (thisjob
->foreground
&& !WIFSTOPPED(status
))) {
1018 i
= WTERMSIG(status
);
1019 if ((i
& 0x7F) < _NSIG
&& strsiglist(i
& 0x7F))
1020 out1str(strsiglist(i
& 0x7F));
1022 out1fmt("Signal %d", i
& 0x7F);
1024 out1str(" (core dumped)");
1027 showjob(thisjob
, pid
, 0, 0);
1030 TRACE(("Not printing status, rootshell=%d, job=%p\n", rootshell
, job
));
1032 thisjob
->changed
= 1;
1040 * Do a wait system call. If job control is compiled in, we accept
1041 * stopped processes. If block is zero, we return a value of zero
1042 * rather than blocking.
1045 waitproc(int block
, int *status
)
1051 flags
= ((rootshell
&& is_interactive
) ? WUNTRACED
: 0);
1055 return waitpid(-1, status
, (block
== 0 ? WNOHANG
: 0) | flags
);
1067 return wait3(status
, flags
, (struct rusage
*)NULL
);
1072 * return 1 if there are stopped jobs, otherwise 0
1074 int job_warning
= 0;
1083 for (jobno
= 1, jp
= jobtab
; jobno
<= njobs
; jobno
++, jp
++) {
1086 if (jp
->state
== JOBSTOPPED
) {
1087 out2str("You have stopped jobs.\n");
1097 * Return a string identifying a command (to be printed by the
1101 STATIC
char *cmdnextc
;
1102 STATIC
int cmdnleft
;
1103 #define MAXCMDTEXT 200
1106 commandtext(union node
*n
)
1110 cmdnextc
= name
= ckmalloc(MAXCMDTEXT
);
1111 cmdnleft
= MAXCMDTEXT
- 4;
1119 cmdtxt(union node
*n
)
1122 struct nodelist
*lp
;
1131 cmdtxt(n
->nbinary
.ch1
);
1133 cmdtxt(n
->nbinary
.ch2
);
1136 cmdtxt(n
->nbinary
.ch1
);
1138 cmdtxt(n
->nbinary
.ch2
);
1141 cmdtxt(n
->nbinary
.ch1
);
1143 cmdtxt(n
->nbinary
.ch2
);
1146 for (lp
= n
->npipe
.cmdlist
; lp
; lp
= lp
->next
) {
1154 cmdtxt(n
->nredir
.n
);
1159 cmdtxt(n
->nredir
.n
);
1163 cmdtxt(n
->nif
.test
);
1165 cmdtxt(n
->nif
.ifpart
);
1174 cmdtxt(n
->nbinary
.ch1
);
1176 cmdtxt(n
->nbinary
.ch2
);
1181 cmdputs(n
->nfor
.var
);
1186 cmdputs(n
->ncase
.expr
->narg
.text
);
1190 cmdputs(n
->narg
.text
);
1194 for (np
= n
->ncmd
.args
; np
; np
= np
->narg
.next
) {
1199 for (np
= n
->ncmd
.redirect
; np
; np
= np
->nfile
.next
) {
1205 cmdputs(n
->narg
.text
);
1208 p
= ">"; i
= 1; goto redir
;
1210 p
= ">>"; i
= 1; goto redir
;
1212 p
= ">&"; i
= 1; goto redir
;
1214 p
= ">|"; i
= 1; goto redir
;
1216 p
= "<"; i
= 0; goto redir
;
1218 p
= "<>"; i
= 0; goto redir
;
1220 p
= "<&"; i
= 0; goto redir
;
1222 if (n
->nfile
.fd
!= i
) {
1223 s
[0] = n
->nfile
.fd
+ '0';
1228 if (n
->type
== NTOFD
|| n
->type
== NFROMFD
) {
1229 if (n
->ndup
.dupfd
>= 0)
1230 s
[0] = n
->ndup
.dupfd
+ '0';
1236 cmdtxt(n
->nfile
.fname
);
1262 while ((c
= *p
++) != '\0') {
1265 else if (c
== CTLVAR
) {
1270 } else if (c
== '=' && subtype
!= 0) {
1271 *q
++ = "}-+?="[(subtype
& VSTYPE
) - VSNORMAL
];
1273 } else if (c
== CTLENDVAR
) {
1275 } else if (c
== CTLBACKQ
|| c
== CTLBACKQ
+CTLQUOTE
)
1276 cmdnleft
++; /* ignore it */
1279 if (--cmdnleft
<= 0) {
1290 static int killpg(grp
, sig
)
1294 return kill(-grp
, sig
);
1299 * $PchId: jobs.c,v 1.7 2006/05/22 12:02:13 philip Exp $