Subject: bin/14558: Sleep 100000001 exits immediately with exit status 0
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kivinen@ssh.fi>
List: netbsd-bugs
Date: 11/12/2001 15:28:33
>Number:         14558
>Category:       bin
>Synopsis:       Sleep 100000001 exits immediately with exit status 0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 12 05:49:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Tero Kivinen
>Release:        NetBSD 1.5Y
>Organization:
SSH Communications Security
>Environment:
System: NetBSD kaakeli.ssh.fi 1.5Y NetBSD 1.5Y (KAAKELI) #47: Wed Oct 31 02:45:43 EET 2001 kivinen@kaakeli.acr.fi:/usr/src/sys/arch/i386/compile/KAAKELI i386
Architecture: i386
Machine: i386
>Description:

	$ /bin/sleep 100000000
	^C
	$ /bin/sleep 100000001
	$ echo $?
	0
	$

	I.e the first /bin/sleep will wait for 100000000 seconds
	(interrupted), but the second will exit immediately without
	returning any error.

	This is because sleep.c does not check the return value of the
	nanosleep. The nanonsleep man page says that it returns EINVAL
	if the value is greater than 1000 million.

	Actually the code in the kern_time.c inside the itimerfix will
	return EINVAL if the value is greater than 100 million, not
	1000 million given in the nanosleep man page. 


>How-To-Repeat:

	/bin/sleep 100000001
	
>Fix:

	Fix the documentation of the nanosleep to have proper amount.
	Check the return value of the nanosleep inside the sleep and
	exit with error code if it fails. Also add text to the sleep
	man page to document this bug.
>Release-Note:
>Audit-Trail:
>Unformatted: