zsh-workers
 help / color / mirror / code / Atom feed
* Job control commands accepting PID
@ 1995-11-13 20:44 Chuck L. Blake
  0 siblings, 0 replies; only message in thread
From: Chuck L. Blake @ 1995-11-13 20:44 UTC (permalink / raw)
  To: zsh-workers

In the man page it states that any job control command can address a job via
PID as well as the % constructs.  In the source, only 'wait' has the support
for this.  The following patch remedies this deficiency.  Any proper integer
argument with no leading '%' is interpreted as a PID.  The selected job is the
one which contains that PID.  No other % semantics are changed. I haven't
tested it a whole lot, but it seems to work. The benefit is that you can do
things like "foo & disown $!". [ Just "disown" fails if for some reason "foo"
is not the "current" job. ]  I just joined the list so forgive me if this is
already done or redundant in some other way.

Chuck


diff -r zsh-2.6-beta11/Src/builtin.c zsh-2.6-beta11-cb/Src/builtin.c
753c753,754
<     int jobnum;
---
>     int jobnum, pid_num;
>     char *last_valid;
754a756,766
>     /* search for PID */
>     pid_num = strtol(s, &last_valid, 10);
>     if (*last_valid == '\0') {
> 	struct process* p;
> 	for (jobnum = MAXJOB - 1; jobnum >= 0; jobnum--)
> 	    if (jobtab[jobnum].stat && jobnum != thisjob)
> 		for(p = jobtab[jobnum].procs; p; p = p->next)
> 		    if (p->pid == pid_num)
> 			return jobnum;
>     }
>     /* search for job name */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-11-13 20:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-11-13 20:44 Job control commands accepting PID Chuck L. Blake

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).