From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13130 invoked by alias); 29 Feb 2012 13:26:53 -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: 30301 Received: (qmail 20936 invoked from network); 29 Feb 2012 13:26:50 -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.112.103.8 as permitted sender) client-ip=10.112.103.8; Authentication-Results: mr.google.com; spf=pass (google.com: domain of dipakgaigole@gmail.com designates 10.112.103.8 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=7wXgn9jMWdqwJ3IjyZfrM7HFLX8ld15/ZNqpbbfP2SI=; b=uIhgNVt6i3PSMTMuygwsErues43nDhAp+WHoMOmd4tBaZCw3Q11I41EC+fLnbS0Jen jctG+lU+vvrSv+tBZHcBZfJ0fFTMRyEbkYeX2s5SOFe8mQndYqO0nN27p2HluPB8dEMJ hcRC6urr2HU9ZxUeAz2NH1ss0c60ECxsSspd4= MIME-Version: 1.0 In-Reply-To: <120226115220.ZM17815@torch.brasslantern.com> References: <120223081441.ZM2715@torch.brasslantern.com> <120224100518.ZM13322@torch.brasslantern.com> <120226115220.ZM17815@torch.brasslantern.com> Date: Wed, 29 Feb 2012 18:27:22 +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 > There are a couple of other cases (e.g., around line 1680) where's also > possible the error should be considered unrecoverable. > > That would make a full patch look something like the following (which > still exits with 1, rather than with 128 like bash, but does exit). > The oautocont stuff goes away because it's handled below the "fatal" > label (outside the visible diff context). =A0The second hunk still might > not cause a proper exit, it's in execpline2() from which it's less clear > to me how to reach the "fatal" condition but it's pretty obvious that > it shouldn't just be falling through in those error states. > > > Index: Src/exec.c > --- ../zsh-forge/current/Src/exec.c =A0 =A0 2012-02-12 13:31:49.000000000= -0800 > +++ Src/exec.c =A02012-02-26 11:47:48.000000000 -0800 > @@ -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) > @@ -1679,9 +1678,13 @@ > > =A0 =A0 =A0 =A0 =A0 =A0if (pipe(synch) < 0) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0zerr("pipe failed: %e", errno); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 lastval =3D errflag =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > =A0 =A0 =A0 =A0 =A0 =A0} else if ((pid =3D zfork(&bgtime)) =3D=3D -1) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0close(synch[0]); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0close(synch[1]); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 lastval =3D errflag =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > =A0 =A0 =A0 =A0 =A0 =A0} else if (pid) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0char dummy, *text; > > @@ -2490,7 +2493,7 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!firstnode(args)) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0zerr("exec requires a comm= and to execute"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0errflag =3D lastval =3D 1; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto fatal; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0uremnode(args, firstnode(args)); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!strcmp(next, "--")) > @@ -2507,12 +2510,12 @@ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!first= node(args)) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ze= rr("exec requires a command to execute"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0er= rflag =3D lastval =3D 1; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret= urn; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 got= o fatal; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!nextn= ode(firstnode(args))) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ze= rr("exec flag -a requires a parameter"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0er= rflag =3D lastval =3D 1; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret= urn; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 got= o fatal; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exec_argv0= =3D (char *) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ge= tdata(nextnode(firstnode(args))); > @@ -2813,15 +2816,12 @@ > > =A0 =A0 =A0 =A0if (pipe(synch) < 0) { > =A0 =A0 =A0 =A0 =A0 =A0zerr("pipe failed: %e", errno); > - =A0 =A0 =A0 =A0 =A0 if (oautocont >=3D 0) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 opts[AUTOCONTINUE] =3D oautocont; > - =A0 =A0 =A0 =A0 =A0 return; > + =A0 =A0 =A0 =A0 =A0 goto fatal; > =A0 =A0 =A0 =A0} else if ((pid =3D zfork(&bgtime)) =3D=3D -1) { > =A0 =A0 =A0 =A0 =A0 =A0close(synch[0]); > =A0 =A0 =A0 =A0 =A0 =A0close(synch[1]); > - =A0 =A0 =A0 =A0 =A0 if (oautocont >=3D 0) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 opts[AUTOCONTINUE] =3D oautocont; > - =A0 =A0 =A0 =A0 =A0 return; > + =A0 =A0 =A0 =A0 =A0 lastval =3D errflag =3D 1; > + =A0 =A0 =A0 =A0 =A0 goto fatal; > =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0if (pid) { > > @@ -3365,6 +3365,7 @@ > =A0 =A0 =A0 =A0 * classify as a builtin) we treat all errors as fatal. > =A0 =A0 =A0 =A0 * The "command" builtin is not special so resets this beh= aviour. > =A0 =A0 =A0 =A0 */ > + =A0 =A0fatal: > =A0 =A0 =A0 =A0if (redir_err || errflag) { > =A0 =A0 =A0 =A0 =A0 =A0if (!isset(INTERACTIVE)) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (forked) I have applied this patch but unfortunately the script still continues even after the fork failures while executing commands from the script. bash-2.05b$ cat /tmp/test1.sh #!/bin/sh x=3D"My default value" x=3D`date` echo $? echo "Current Date is:" "$x" date echo $? bash-2.05b$ zsh /tmp/test1.sh /tmp/test1.sh:3: fork failed: resource temporarily unavailable 1 Current Date is: My default value /tmp/test1.sh:6: fork failed: resource temporarily unavailable 1 bash-2.05b$ Can you please check this on your end? Thanks, Dipak