From owner-freebsd-current Fri Feb 19 18:58:53 1999 Delivered-To: freebsd-current@freebsd.org Received: from bolero-x.rahul.net (bolero.rahul.net [192.160.13.1]) by hub.freebsd.org (Postfix) with SMTP id F24B110E7B for ; Fri, 19 Feb 1999 18:58:48 -0800 (PST) (envelope-from dhesi@rahul.net) Received: from waltz.rahul.net by bolero-x.rahul.net with SMTP id AA11946 (5.67b8/IDA-1.5 for ); Fri, 19 Feb 1999 18:58:47 -0800 Received: by waltz.rahul.net (5.67b8/jive-a2i-1.0) id AA26119; Fri, 19 Feb 1999 18:58:32 -0800 Message-Id: <199902200258.AA26119@waltz.rahul.net> To: current@freebsd.org Subject: Re: sh(1) -- exec vs. fork In-Reply-To: Message from Mikhail Teterin of Fri, 19 Feb 99 11:43:59 -0500 Date: Fri, 19 Feb 99 18:58:32 -0800 From: Rahul Dhesi Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Many years ago I posted a shell script to Usenet in which I prepended a line with 'exec', in an attempt to avoid having a shell process hanging around doing a wait(). David Korn himself (of Korn shell fame) responded saying this was not necessary, as the shell would do exec() anyway. I check with trace() on a Sun and he seemed to be right. This was for the classic Bourne shell many years ago. But I just checked /bin/sh on 3.1-RELEASE with ktrace and the above does not seem to be true. I get drastically different traces for #! /bin/sh exec /bin/pwd and #! /bin/sh /bin/pwd Rahul > Date: Fri, 19 Feb 99 11:43:59 EST > From: Mikhail Teterin > To: current@freebsd.org > Message-Id: <199902191644.LAA08791@misha.cisco.com> > Subject: sh(1) -- exec vs. fork > Reply-To: mi@aldan.algebra.com > I just finished going through a couple of crontabs prepending the > command-lines with ``exec'', when it hit me. > > Can shell itself recognize, there will be no more commands and just > proceed to exec without forking? What would this break? ... To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message