From 3b08e0fcf357c1a905c5e59731930528fb94a0b1 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 8 Feb 2019 23:03:28 +0000 Subject: [PATCH] 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 --- sbin/dhclient/dhclient.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index a6e0f2d169ce..c65ff81b5cfc 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -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