jobs.c (222684) | jobs.c (223024) |
---|---|
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 --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#ifndef lint 34#if 0 35static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> | 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 --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#ifndef lint 34#if 0 35static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/bin/sh/jobs.c 222684 2011-06-04 15:05:52Z jilles $"); | 39__FBSDID("$FreeBSD: head/bin/sh/jobs.c 223024 2011-06-12 23:06:04Z jilles $"); |
40 41#include <sys/ioctl.h> 42#include <sys/param.h> 43#include <sys/resource.h> 44#include <sys/time.h> 45#include <sys/wait.h> 46#include <errno.h> 47#include <fcntl.h> --- 17 unchanged lines hidden (view full) --- 65#include "options.h" 66#include "trap.h" 67#include "syntax.h" 68#include "input.h" 69#include "output.h" 70#include "memalloc.h" 71#include "error.h" 72#include "mystring.h" | 40 41#include <sys/ioctl.h> 42#include <sys/param.h> 43#include <sys/resource.h> 44#include <sys/time.h> 45#include <sys/wait.h> 46#include <errno.h> 47#include <fcntl.h> --- 17 unchanged lines hidden (view full) --- 65#include "options.h" 66#include "trap.h" 67#include "syntax.h" 68#include "input.h" 69#include "output.h" 70#include "memalloc.h" 71#include "error.h" 72#include "mystring.h" |
73#include "var.h" |
|
73 74 75static struct job *jobtab; /* array of jobs */ 76static int njobs; /* size of array */ 77MKINIT pid_t backgndpid = -1; /* pid of last background process */ 78MKINIT struct job *bgjob = NULL; /* last background process */ 79#if JOBS 80static struct job *jobmru; /* most recently used job list */ --- 712 unchanged lines hidden (view full) --- 793 int i; 794 795 TRACE(("Child shell %d\n", (int)getpid())); 796 wasroot = rootshell; 797 rootshell = 0; 798 handler = &main_handler; 799 closescript(); 800 INTON; | 74 75 76static struct job *jobtab; /* array of jobs */ 77static int njobs; /* size of array */ 78MKINIT pid_t backgndpid = -1; /* pid of last background process */ 79MKINIT struct job *bgjob = NULL; /* last background process */ 80#if JOBS 81static struct job *jobmru; /* most recently used job list */ --- 712 unchanged lines hidden (view full) --- 794 int i; 795 796 TRACE(("Child shell %d\n", (int)getpid())); 797 wasroot = rootshell; 798 rootshell = 0; 799 handler = &main_handler; 800 closescript(); 801 INTON; |
802 forcelocal = 0; |
|
801 clear_traps(); 802#if JOBS 803 jobctl = 0; /* do job control only in root shell */ 804 if (wasroot && mode != FORK_NOJOB && mflag) { 805 if (jp == NULL || jp->nprocs == 0) 806 pgrp = getpid(); 807 else 808 pgrp = jp->ps[0].pid; --- 307 unchanged lines hidden (view full) --- 1116{ 1117 return backgndpid != -1; 1118} 1119 1120 1121pid_t 1122backgndpidval(void) 1123{ | 803 clear_traps(); 804#if JOBS 805 jobctl = 0; /* do job control only in root shell */ 806 if (wasroot && mode != FORK_NOJOB && mflag) { 807 if (jp == NULL || jp->nprocs == 0) 808 pgrp = getpid(); 809 else 810 pgrp = jp->ps[0].pid; --- 307 unchanged lines hidden (view full) --- 1118{ 1119 return backgndpid != -1; 1120} 1121 1122 1123pid_t 1124backgndpidval(void) 1125{ |
1124 if (bgjob != NULL) | 1126 if (bgjob != NULL && !forcelocal) |
1125 bgjob->remembered = 1; 1126 return backgndpid; 1127} 1128 1129/* 1130 * Return a string identifying a command (to be printed by the 1131 * jobs command. 1132 */ --- 222 unchanged lines hidden --- | 1127 bgjob->remembered = 1; 1128 return backgndpid; 1129} 1130 1131/* 1132 * Return a string identifying a command (to be printed by the 1133 * jobs command. 1134 */ --- 222 unchanged lines hidden --- |