From owner-freebsd-questions@FreeBSD.ORG Wed Apr 4 08:21:55 2012 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C18FD106564A for ; Wed, 4 Apr 2012 08:21:55 +0000 (UTC) (envelope-from perryh@pluto.rain.com) Received: from agora.rdrop.com (unknown [IPv6:2607:f678:1010::34]) by mx1.freebsd.org (Postfix) with ESMTP id 9BA9A8FC15 for ; Wed, 4 Apr 2012 08:21:55 +0000 (UTC) Received: from agora.rdrop.com (66@localhost [127.0.0.1]) by agora.rdrop.com (8.13.1/8.12.7) with ESMTP id q348Lt9E063255 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 4 Apr 2012 01:21:55 -0700 (PDT) (envelope-from perryh@pluto.rain.com) Received: (from uucp@localhost) by agora.rdrop.com (8.13.1/8.14.2/Submit) with UUCP id q348Ltt2063254; Wed, 4 Apr 2012 01:21:55 -0700 (PDT) (envelope-from perryh@pluto.rain.com) Received: from fbsd81 ([192.168.200.81]) by pluto.rain.com (4.1/SMI-4.1-pluto-M2060407) id AA26129; Wed, 4 Apr 12 01:04:07 PDT Date: Wed, 04 Apr 2012 08:03:11 -0700 From: perryh@pluto.rain.com To: illoai@gmail.com Message-Id: <4f7c62af.TE2lRux2ew4+bRu8%perryh@pluto.rain.com> References: In-Reply-To: User-Agent: nail 11.25 7/29/05 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: questions@freebsd.org Subject: Re: current pids per tty X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2012 08:21:55 -0000 "illoai@gmail.com" wrote: > (there is an executable named /usr/bin/jobs, but . . . > well run "cat /usr/bin/jobs" & see for yourself). Whoa! Does /usr/bin/jobs even work? $ cat /usr/bin/jobs #!/bin/sh # $FreeBSD: src/usr.bin/alias/generic.sh,v 1.2.10.1.4.1 2010/06/14 02:09:06 kensmith Exp $ # This file is in the public domain. builtin ${0##*/} ${1+"$@"} It looks as if generic.sh intends to have the same effect as the builtin matching the name under which the script is run, but at least for "jobs" I don't think it will DTRT because it will run in the wrong context: * The builtin "jobs" command will report all background jobs known to the shell in which it is issued. * Because it is a shebang script, running /usr/bin/jobs will cause the shell in which it is run to fork/exec an instance of /bin/sh, and that instance will execute the /usr/bin/jobs script, thus it will will be the new /bin/sh instance that executes _its_ builtin "jobs" command -- reporting nothing, since _that_ instance has not put anything into the background (and has no knowledge of what-all its parent shell may have put in the background).