Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Feb 2019 23:03:29 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r343922 - head/sbin/dhclient
Message-ID:  <201902082303.x18N3TV7093187@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Fri Feb  8 23:03:28 2019
New Revision: 343922
URL: https://svnweb.freebsd.org/changeset/base/343922

Log:
  dhclient: Return non-zero status when script exits due to a signal
  
  r343896 made it such that a non-zero exit status was passed through, but was
  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.
  
  Instead, translate the wait status into 8 bits the same way as the shell
  calculates $?.
  
  Reviewed by:	kib, Nash Kaminski
  MFC after:	1 week

Modified:
  head/sbin/dhclient/dhclient.c

Modified: head/sbin/dhclient/dhclient.c
==============================================================================
--- head/sbin/dhclient/dhclient.c	Fri Feb  8 22:10:40 2019	(r343921)
+++ head/sbin/dhclient/dhclient.c	Fri Feb  8 23:03:28 2019	(r343922)
@@ -2348,7 +2348,8 @@ priv_script_go(void)
 	if (ip)
 		script_flush_env(ip->client);
 
-	return WEXITSTATUS(wstatus);
+	return (WIFEXITED(wstatus) ?
+	    WEXITSTATUS(wstatus) : 128 + WTERMSIG(wstatus));
 }
 
 void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902082303.x18N3TV7093187>