From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21958 invoked by alias); 24 Feb 2012 11:08:10 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30266 Received: (qmail 28840 invoked from network); 24 Feb 2012 11:08:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.215.43 as permitted sender) Received-SPF: pass (google.com: domain of dipakgaigole@gmail.com designates 10.152.147.1 as permitted sender) client-ip=10.152.147.1; Authentication-Results: mr.google.com; spf=pass (google.com: domain of dipakgaigole@gmail.com designates 10.152.147.1 as permitted sender) smtp.mail=dipakgaigole@gmail.com; dkim=pass header.i=dipakgaigole@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=P+xkpoctkxkCcZ0FDaGi9e17zZEGgJST8tuQnkNaaUM=; b=ihI13mFEQ8Gkl1XCx3t/ZDESpa61Ar0cVnuBfL0afrs/Rwj2OLI03l6LzYwq89EbJq J2upAAMoxZjzGfBrvBkj/tRhz/A3puCGqP04ertkLHEir2C2aFvJKevY2tcmKCpM562H /LxuC5yKW044vntSxteE5jkgOls2Is7IjCzfs= MIME-Version: 1.0 In-Reply-To: <120223081441.ZM2715@torch.brasslantern.com> References: <120223081441.ZM2715@torch.brasslantern.com> Date: Fri, 24 Feb 2012 16:38:01 +0530 Message-ID: Subject: Re: zsh behavior when fork() failed From: Dipak Gaigole To: Bart Schaefer Cc: zsh-workers@zsh.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Thu, Feb 23, 2012 at 9:44 PM, Bart Schaefer wrote: > > Perhaps you mean a case where script A calls script B, then script B > fails but script A proceeds because the error wasn't propagated? Yes, you are right. This is what I mean to say. > > Index: Src/exec.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Src/exec.c =A020 Dec 2011 17:13:38 -0000 =A0 =A0 =A01.43 > +++ Src/exec.c =A023 Feb 2012 16:07:50 -0000 > @@ -1617,9 +1617,8 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (list_pipe || (pline_level && !(jn->stat = & STAT_SUBJOB))))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0deletejob(jn, 0); > =A0 =A0 =A0 =A0 =A0 =A0thisjob =3D pj; > - > =A0 =A0 =A0 =A0} > - =A0 =A0 =A0 if (slflags & WC_SUBLIST_NOT) > + =A0 =A0 =A0 if ((slflags & WC_SUBLIST_NOT) && !errflag) > =A0 =A0 =A0 =A0 =A0 =A0lastval =3D !lastval; > =A0 =A0 } > =A0 =A0 if (!pline_level) > @@ -2810,6 +2820,7 @@ > =A0 =A0 =A0 =A0 =A0 =A0close(synch[1]); > =A0 =A0 =A0 =A0 =A0 =A0if (oautocont >=3D 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0opts[AUTOCONTINUE] =3D oautocont; > + =A0 =A0 =A0 =A0 =A0 lastval =3D errflag =3D 1; > =A0 =A0 =A0 =A0 =A0 =A0return; > =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0if (pid) { > I have applied this patch and the newly built zsh returns proper $? (i.e. 1) whenever fork fails. So this has fixed the behavior of error propagation, but the script behavior still looks different. Here is a simple script example: bash-2.05b$ cat /tmp/test.sh #!/bin/sh x=3D"My default value" x=3D`date` echo $? echo "Current Date is:" "$x" date echo $? bash-2.05b$ BASH: bash-2.05b$ bash -x /tmp/test.sh + x=3DMy default value /tmp/test.sh: fork: Resource temporarily unavailable bash-2.05b$ echo $? 128 bash-2.05b$ KSH: bash-2.05b$ ksh -x /tmp/test.sh + x=3DMy default value /tmp/test.sh[3]: cannot fork - try again bash-2.05b$ echo $? 1 bash-2.05b$ ZSH: (Applied above code patch) bash-2.05b$ zsh -x /tmp/test.sh +/tmp/test.sh:2> x=3D'My default value' +/tmp/test.sh:3> x=3D/tmp/test.sh:3: fork failed: resource temporarily unav= ailable +/tmp/test.sh:4> echo 1 1 +/tmp/test.sh:5> echo 'Current Date is:' 'My default value' Current Date is: My default value /tmp/test.sh:7: fork failed: resource temporarily unavailable +/tmp/test.sh:8> echo 1 1 bash-2.05b$ echo $? 0 bash-2.05b$ As we can see that zsh continues even if it knows that it has failed in fork and finally the script return status is 0. Also checking for $? after each command is not feasible. So doesn't this zsh behavior looks misleading? Thanks, Dipak