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 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" |
73#include "var.h" |
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; |
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{ |
1126 if (bgjob != NULL && !forcelocal) |
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 --- |