NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/39574: /bin/echo always exits zero even when it encounters I/O errors

>Number:         39574
>Category:       bin
>Synopsis:       /bin/echo always exits zero even when it encounters I/O errors
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 17 22:25:00 +0000 2008
>Originator:     Ed Ravin
>Release:        4.0
Public Access Networks Corp
NetBSD 4.0 NetBSD 4.0 (PANIX-XEN3U-USER) #1: Tue Apr  1 
23:24:49 EDT 2008

We are having trouble with a shell script that loops on stdin, prompting users 
for information, that goes into infinite loop when the tty is revoked.

One of the problems seems to be that /bin/echo always exits with zero, even if 
it encounters I/O errors trying to write to stdout.  This is bad practice, and 
it also contravenes the documentation:

   The echo utility exits 0 on success, and >0 if an error occurs.

Confirmed by reading src/bin/echo.c (a very short program) that the return 
value from printf() and putchar() is never checked and that it always exits 
with zero.

Home | Main Index | Thread Index | Old Index