jobs.c (b97fa2ef508bb1cc99621edb8b6d03845b55b8bd) | jobs.c (afb033d5c4f01a464f57fe8e68d741246d9df492) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * |
36 * $Id$ | 36 * $Id: jobs.c,v 1.12 1997/02/22 13:58:29 peter Exp $ |
37 */ 38 39#ifndef lint 40static char const sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; 41#endif /* not lint */ 42 43#include <fcntl.h> 44#include <signal.h> --- 6 unchanged lines hidden (view full) --- 51#include <sys/wait.h> 52#include <sys/time.h> 53#include <sys/resource.h> 54#endif 55#include <sys/ioctl.h> 56 57#include "shell.h" 58#if JOBS | 37 */ 38 39#ifndef lint 40static char const sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; 41#endif /* not lint */ 42 43#include <fcntl.h> 44#include <signal.h> --- 6 unchanged lines hidden (view full) --- 51#include <sys/wait.h> 52#include <sys/time.h> 53#include <sys/resource.h> 54#endif 55#include <sys/ioctl.h> 56 57#include "shell.h" 58#if JOBS |
59#ifdef OLD_TTY_DRIVER | 59#if OLD_TTY_DRIVER |
60#include "sgtty.h" 61#else 62#include <termios.h> 63#endif 64#undef CEOF /* syntax.h redefines this */ 65#endif 66#include "redir.h" 67#include "show.h" --- 367 unchanged lines hidden (view full) --- 435 * Convert a job name to a job structure. 436 */ 437 438STATIC struct job * 439getjob(name) 440 char *name; 441 { 442 int jobno; | 60#include "sgtty.h" 61#else 62#include <termios.h> 63#endif 64#undef CEOF /* syntax.h redefines this */ 65#endif 66#include "redir.h" 67#include "show.h" --- 367 unchanged lines hidden (view full) --- 435 * Convert a job name to a job structure. 436 */ 437 438STATIC struct job * 439getjob(name) 440 char *name; 441 { 442 int jobno; |
443 register struct job *jp; | 443 struct job *jp; |
444 int pid; 445 int i; 446 447 if (name == NULL) { 448#if JOBS 449currentjob: 450 if ((jobno = curjob) == 0 || jobtab[jobno - 1].used == 0) 451 error("No current job"); --- 7 unchanged lines hidden (view full) --- 459 if (jobno > 0 && jobno <= njobs 460 && jobtab[jobno - 1].used != 0) 461 return &jobtab[jobno - 1]; 462#if JOBS 463 } else if (name[1] == '%' && name[2] == '\0') { 464 goto currentjob; 465#endif 466 } else { | 444 int pid; 445 int i; 446 447 if (name == NULL) { 448#if JOBS 449currentjob: 450 if ((jobno = curjob) == 0 || jobtab[jobno - 1].used == 0) 451 error("No current job"); --- 7 unchanged lines hidden (view full) --- 459 if (jobno > 0 && jobno <= njobs 460 && jobtab[jobno - 1].used != 0) 461 return &jobtab[jobno - 1]; 462#if JOBS 463 } else if (name[1] == '%' && name[2] == '\0') { 464 goto currentjob; 465#endif 466 } else { |
467 register struct job *found = NULL; | 467 struct job *found = NULL; |
468 for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) { 469 if (jp->used && jp->nprocs > 0 470 && prefix(name + 1, jp->ps[0].cmd)) { 471 if (found) 472 error("%s: ambiguous", name); 473 found = jp; 474 } 475 } --- 205 unchanged lines hidden (view full) --- 681 * Unfortunately, some programs want to do a bit of cleanup and then 682 * exit on interrupt; unless these processes terminate themselves by 683 * sending a signal to themselves (instead of calling exit) they will 684 * confuse this approach. 685 */ 686 687int 688waitforjob(jp) | 468 for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) { 469 if (jp->used && jp->nprocs > 0 470 && prefix(name + 1, jp->ps[0].cmd)) { 471 if (found) 472 error("%s: ambiguous", name); 473 found = jp; 474 } 475 } --- 205 unchanged lines hidden (view full) --- 681 * Unfortunately, some programs want to do a bit of cleanup and then 682 * exit on interrupt; unless these processes terminate themselves by 683 * sending a signal to themselves (instead of calling exit) they will 684 * confuse this approach. 685 */ 686 687int 688waitforjob(jp) |
689 register struct job *jp; | 689 struct job *jp; |
690 { 691#if JOBS 692 int mypgrp = getpgrp(); 693#endif 694 int status; 695 int st; 696 697 INTOFF; --- 204 unchanged lines hidden (view full) --- 902 903/* 904 * return 1 if there are stopped jobs, otherwise 0 905 */ 906int job_warning = 0; 907int 908stoppedjobs() 909{ | 690 { 691#if JOBS 692 int mypgrp = getpgrp(); 693#endif 694 int status; 695 int st; 696 697 INTOFF; --- 204 unchanged lines hidden (view full) --- 902 903/* 904 * return 1 if there are stopped jobs, otherwise 0 905 */ 906int job_warning = 0; 907int 908stoppedjobs() 909{ |
910 register int jobno; 911 register struct job *jp; | 910 int jobno; 911 struct job *jp; |
912 913 if (job_warning) 914 return (0); 915 for (jobno = 1, jp = jobtab; jobno <= njobs; jobno++, jp++) { 916 if (jp->used == 0) 917 continue; 918 if (jp->state == JOBSTOPPED) { 919 out2str("You have stopped jobs.\n"); --- 155 unchanged lines hidden (view full) --- 1075} 1076 1077 1078 1079STATIC void 1080cmdputs(s) 1081 char *s; 1082 { | 912 913 if (job_warning) 914 return (0); 915 for (jobno = 1, jp = jobtab; jobno <= njobs; jobno++, jp++) { 916 if (jp->used == 0) 917 continue; 918 if (jp->state == JOBSTOPPED) { 919 out2str("You have stopped jobs.\n"); --- 155 unchanged lines hidden (view full) --- 1075} 1076 1077 1078 1079STATIC void 1080cmdputs(s) 1081 char *s; 1082 { |
1083 register char *p, *q; 1084 register char c; | 1083 char *p, *q; 1084 char c; |
1085 int subtype = 0; 1086 1087 if (cmdnleft <= 0) 1088 return; 1089 p = s; 1090 q = cmdnextc; 1091 while ((c = *p++) != '\0') { 1092 if (c == CTLESC) --- 24 unchanged lines hidden --- | 1085 int subtype = 0; 1086 1087 if (cmdnleft <= 0) 1088 return; 1089 p = s; 1090 q = cmdnextc; 1091 while ((c = *p++) != '\0') { 1092 if (c == CTLESC) --- 24 unchanged lines hidden --- |