Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Feb 2019 08:23:15 -0600
From:      Nash Kaminski <nashkaminski@gmail.com>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        Konstantin Belousov <kib@freebsd.org>, Ryan Moeller <ryan@ixsystems.com>, src-committers@freebsd.org,  svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r343896 - head/sbin/dhclient
Message-ID:  <CAEF9=Z6xjHkoRgDunpCrnLP1rf%2Bw3Rru5QRoFzGcDg_bK_LhdQ@mail.gmail.com>
In-Reply-To: <20190208132301.GA5715@stack.nl>
References:  <201902080736.x187a8LM002846@repo.freebsd.org> <20190208132301.GA5715@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
I would be in favor of Jilles' implementation as well, since fundamentally
dhclient just tests for zero/nonzero exit status and therefore what is
critical is making sure such status is nonzero in *any* failure case of
dhclient-script, including abnormal termination via signal.

- Nash

On Fri, Feb 8, 2019, 7:23 AM Jilles Tjoelker <jilles@stack.nl wrote:

> On Fri, Feb 08, 2019 at 07:36:08AM +0000, Konstantin Belousov wrote:
> > Author: kib
> > Date: Fri Feb  8 07:36:08 2019
> > New Revision: 343896
> > URL: https://svnweb.freebsd.org/changeset/base/343896
>
> > Log:
> >   Correctly return exit status from the exited process.
>
> >   This is also OpenBSD rev. 1.117, as pointed out by
> >   Ryan Moeller <ryan@ixsystems.com>.
>
> >   Submitted by:       Nash Kaminski <nashkaminski@gmail.com>
> >   MFC after:  1 week
>
> > Modified:
> >   head/sbin/dhclient/dhclient.c
>
> > Modified: head/sbin/dhclient/dhclient.c
> >
> ==============================================================================
> > --- head/sbin/dhclient/dhclient.c     Fri Feb  8 06:19:28 2019
> (r343895)
> > +++ head/sbin/dhclient/dhclient.c     Fri Feb  8 07:36:08 2019
> (r343896)
> > @@ -2348,7 +2348,7 @@ priv_script_go(void)
> >       if (ip)
> >               script_flush_env(ip->client);
> >
> > -     return (wstatus & 0xff);
> > +     return WEXITSTATUS(wstatus);
> >  }
> >
> >  void
>
> This is probably a big improvement in practice, but it is still wrong if
> the script exits on a signal. POSIX does not say what the WEXITSTATUS
> macro returns in this case and in practice 0 is a common value. Perhaps
> you want
>
> return WIFEXITED(wstatus) ? WEXITSTATUS(wstatus) : 128 + WTERMSIG(wstatus);
>
> imitating what the shell does to translate a wait status into 8 bits?
>
> --
> Jilles Tjoelker
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAEF9=Z6xjHkoRgDunpCrnLP1rf%2Bw3Rru5QRoFzGcDg_bK_LhdQ>