jobs.c (263453) | jobs.c (268920) |
---|---|
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 263453 2014-03-20 22:38:13Z jilles $"); | 39__FBSDID("$FreeBSD: head/bin/sh/jobs.c 268920 2014-07-20 12:06:52Z 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> --- 509 unchanged lines hidden (view full) --- 557 * Convert a job name to a job structure. 558 */ 559 560static struct job * 561getjob_nonotfound(const char *name) 562{ 563 int jobno; 564 struct job *found, *jp; | 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> --- 509 unchanged lines hidden (view full) --- 557 * Convert a job name to a job structure. 558 */ 559 560static struct job * 561getjob_nonotfound(const char *name) 562{ 563 int jobno; 564 struct job *found, *jp; |
565 size_t namelen; |
|
565 pid_t pid; 566 int i; 567 568 if (name == NULL) { 569#if JOBS 570currentjob: if ((jp = getcurjob(NULL)) == NULL) 571 error("No current job"); 572 return (jp); --- 25 unchanged lines hidden (view full) --- 598 if (found) 599 error("%s: ambiguous", name); 600 found = jp; 601 } 602 } 603 if (found != NULL) 604 return (found); 605 } else { | 566 pid_t pid; 567 int i; 568 569 if (name == NULL) { 570#if JOBS 571currentjob: if ((jp = getcurjob(NULL)) == NULL) 572 error("No current job"); 573 return (jp); --- 25 unchanged lines hidden (view full) --- 599 if (found) 600 error("%s: ambiguous", name); 601 found = jp; 602 } 603 } 604 if (found != NULL) 605 return (found); 606 } else { |
607 namelen = strlen(name); |
|
606 found = NULL; 607 for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) { 608 if (jp->used && jp->nprocs > 0 | 608 found = NULL; 609 for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) { 610 if (jp->used && jp->nprocs > 0 |
609 && prefix(name + 1, jp->ps[0].cmd)) { | 611 && strncmp(jp->ps[0].cmd, name + 1, 612 namelen - 1) == 0) { |
610 if (found) 611 error("%s: ambiguous", name); 612 found = jp; 613 } 614 } 615 if (found) 616 return found; 617 } --- 852 unchanged lines hidden --- | 613 if (found) 614 error("%s: ambiguous", name); 615 found = jp; 616 } 617 } 618 if (found) 619 return found; 620 } --- 852 unchanged lines hidden --- |