Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Jun 1997 06:51:47 +0900 (JST)
From:      sanewo@ba2.so-net.or.jp
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/3780: WEXITSTATUS() may return nagative value, which causes sh to generate bad $?
Message-ID:  <199706042151.GAA20600@sanewo.ba2.so-net.or.jp>
Resent-Message-ID: <199706042200.PAA15583@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         3780
>Category:       bin
>Synopsis:       WEXITSTATUS() may return nagative value, which causes sh to generate bad $?
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun  4 15:00:03 PDT 1997
>Last-Modified:
>Originator:     Takanori Saneto
>Organization:
an individual
>Release:        FreeBSD 3.0-CURRENT i386
>Environment:

	current as of June 1 1997.

>Description:

	When subprocess of /bin/sh exit(2)s with negative argument, the value of $? bacomes
	bad. (-/ instead of -1, for example)

>How-To-Repeat:

	# /bin/sh -c 'perl -e "exit -1"; echo $?'
	-/

>Fix:

*** bin/sh/expand.c.org	Thu Jun  5 06:45:18 1997
--- bin/sh/expand.c	Thu Jun  5 06:45:43 1997
***************
*** 1388,1393 ****
--- 1388,1394 ----
  
  	temp[31] = '\0';
  
+ 	if (neg) num = -num;
  	do {
  		*--p = num % 10 + '0';
  	} while ((num /= 10) != 0);

BTW, should WEXITSTATUS() return unsigned value? (I don't know what POSIX says about this)
>Audit-Trail:
>Unformatted:



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