From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 173 invoked from network); 5 Sep 2007 15:30:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 5 Sep 2007 15:30:30 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 94420 invoked from network); 5 Sep 2007 15:30:24 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 5 Sep 2007 15:30:24 -0000 Received: (qmail 27846 invoked by alias); 5 Sep 2007 15:30:14 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11817 Received: (qmail 27836 invoked from network); 5 Sep 2007 15:30:13 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 5 Sep 2007 15:30:13 -0000 Received: (qmail 93146 invoked from network); 5 Sep 2007 15:30:13 -0000 Received: from vms042pub.verizon.net (206.46.252.42) by a.mx.sunsite.dk with SMTP; 5 Sep 2007 15:30:06 -0000 Received: from torch.brasslantern.com ([71.116.91.65]) by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JNW000D3J246288@vms042.mailsrvcs.net> for zsh-users@sunsite.dk; Wed, 05 Sep 2007 10:30:05 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id l85FU3oE027538 for ; Wed, 05 Sep 2007 08:30:03 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id l85FU2Oc027537 for zsh-users@sunsite.dk; Wed, 05 Sep 2007 08:30:02 -0700 Date: Wed, 05 Sep 2007 08:30:00 -0700 From: Bart Schaefer Subject: Re: fg jobs info In-reply-to: <200709050928.l859Su9h016042@news01.csr.com> To: zsh-users@sunsite.dk Message-id: <070905083002.ZM27536@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <20070902154306.35880.qmail@smasher.org> <070902105953.ZM22915@torch.brasslantern.com> <20070903163147.GA14017@mastermind> <20070904111631.81486.qmail@smasher.org> <070904083104.ZM25598@torch.brasslantern.com> <20070905090302.72429.qmail@smasher.org> <200709050928.l859Su9h016042@news01.csr.com> Comments: In reply to Peter Stephenson "Re: fg jobs info" (Sep 5, 10:28am) On Sep 5, 10:28am, Peter Stephenson wrote: } } > add a variable that automagically returns the text of the } > fg'd job. } } That's $jobtexts. Well ... $jobtexts returns the text of any/all of the jobs, by job number. That doesn't solve the problem of knowing which job number is the job in the foreground. OTOH, I can't figure out how knowing that could be useful, because when a job is in the foreground the shell is blocked in zwaitjob(), so there's no way for it to do anything useful with the job text. Furthermore $jobtexts never contains the text of the current job if that job is *started* in the foreground; it only has jobs that were at some point backgrounded or stopped (at least as far as the user of the shell is able to tell, see previous point). What Atom wants is the text of the job that's *about to be* in the foreground, the instant *before* the shell hands over control of the TTY and calls zwaitjob(), plus a hook to be able to do something with that information. On linux I think a better way to handle this would be to have another process monitoring the /proc directory. The foreground job for each TTY is always the one where the 5th and 8th fields of /proc/<->/stat are equal, in which case /proc/<->/cmdline gives the job text. E.g. all_fg_jobs() { emulate -L zsh local -a j local x for x in /proc/<->/stat do j=( $(<$x) ) # $j[7] is 0 for jobs having no TTY if (( $j[7] && $j[5] == $j[8] )) then print -R ${(ps:\0:)"$(