jobs.c (213925) | jobs.c (216199) |
---|---|
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 213925 2010-10-16 12:40:00Z jilles $"); | 39__FBSDID("$FreeBSD: head/bin/sh/jobs.c 216199 2010-12-05 16:09:03Z 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> --- 255 unchanged lines hidden (view full) --- 303 304static void 305showjob(struct job *jp, pid_t pid, int mode) 306{ 307 char s[64]; 308 struct procstat *ps; 309 struct job *j; 310 int col, curr, i, jobno, prev, procno; | 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> --- 255 unchanged lines hidden (view full) --- 303 304static void 305showjob(struct job *jp, pid_t pid, int mode) 306{ 307 char s[64]; 308 struct procstat *ps; 309 struct job *j; 310 int col, curr, i, jobno, prev, procno; |
311 pid_t ppid; | |
312 char c; 313 314 procno = (mode == SHOWJOBS_PGIDS) ? 1 : jp->nprocs; 315 jobno = jp - jobtab + 1; 316 curr = prev = 0; 317#if JOBS 318 if ((j = getcurjob(NULL)) != NULL) { 319 curr = j - jobtab + 1; 320 if ((j = getcurjob(j)) != NULL) 321 prev = j - jobtab + 1; 322 } 323#endif 324 for (ps = jp->ps ; ; ps++) { /* for each process */ 325 if (mode == SHOWJOBS_PIDS || mode == SHOWJOBS_PGIDS) { | 311 char c; 312 313 procno = (mode == SHOWJOBS_PGIDS) ? 1 : jp->nprocs; 314 jobno = jp - jobtab + 1; 315 curr = prev = 0; 316#if JOBS 317 if ((j = getcurjob(NULL)) != NULL) { 318 curr = j - jobtab + 1; 319 if ((j = getcurjob(j)) != NULL) 320 prev = j - jobtab + 1; 321 } 322#endif 323 for (ps = jp->ps ; ; ps++) { /* for each process */ 324 if (mode == SHOWJOBS_PIDS || mode == SHOWJOBS_PGIDS) { |
326 ppid = (mode == SHOWJOBS_PIDS) ? ps->pid : 327 getpgid(ps->pid); 328 out1fmt("%d\n", (int)ppid); | 325 out1fmt("%d\n", (int)ps->pid); |
329 goto skip; 330 } 331 if (mode != SHOWJOBS_VERBOSE && ps != jp->ps && pid == 0) 332 goto skip; 333 if (pid != 0 && pid != ps->pid) 334 goto skip; 335 if (jobno == curr && ps == jp->ps) 336 c = '+'; --- 984 unchanged lines hidden --- | 326 goto skip; 327 } 328 if (mode != SHOWJOBS_VERBOSE && ps != jp->ps && pid == 0) 329 goto skip; 330 if (pid != 0 && pid != ps->pid) 331 goto skip; 332 if (jobno == curr && ps == jp->ps) 333 c = '+'; --- 984 unchanged lines hidden --- |