all: check stdout and stderr status at exit

If stream status is not checked at the end of execution below problem
would not report error, or non-zero exit code.  The uptime is just an
example same was true with all commands of the project.

$ uptime >&- ; echo $?
uptime: write error: Bad file descriptor
1
$ uptime >/dev/full ; echo $?
uptime: write error: No space left on device
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola
2012-03-23 13:32:24 +01:00
parent c7cf98b0e0
commit 52269d22f3
17 changed files with 47 additions and 11 deletions

View File

@ -36,6 +36,7 @@
#include "../proc/version.h"
#include "../proc/wchan.h"
#include "../include/fileutils.h"
#include "common.h"
#ifndef SIGCHLD
@ -531,6 +532,7 @@ static void fancy_spew(void){
/***** no comment */
int main(int argc, char *argv[]){
atexit(close_stdout);
myname = strrchr(*argv, '/');
if (myname) ++myname; else myname = *argv;