>Number:         158206
>Category:       misc
>Synopsis:       /bin/sh doesn't properly return IO errors to conditionals in a 
>script
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 23 16:10:14 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Chris Ulrich
>Release:        amd64 freebsd 8.2-RELEASE
>Organization:
CSN Stores
>Environment:
FreeBSD svn.csnzoo.com 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 02:41:51 
UTC 2011     [email protected]:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
a /bin/sh script writing to a closed file descriptor doesn't pass the IO error 
it receives from the write to the script itself.


>How-To-Repeat:
write these two scripts:

#!/bin/sh
while echo -n . ; do : ; done

and

#!/bin/sh
while printf . ; do : ; done


now run each script with std-out closed, ie (assuming your interactive shell is 
bourne shell or similar):

$ sh ./bomb-echo.sh >&-

or 

$ sh ./bomb-printf.sh >&-


both should exit instantly because echo *should* get an error from writing to a 
closed file descriptor.  Instead both spin madly until they get a kill signal 
or you truss them (the last bit of stuff you see when you truss them is:

72238: sigprocmask(SIG_SETMASK,0x0,0x0)          = 0 (0x0)
72238: write(1,".",1)                            ERR#9 'Bad file descriptor'
72238: process exit, rval = 0

which itself is another 
>Fix:
sorry.  don't know C.

>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to