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:
parent
c7cf98b0e0
commit
52269d22f3
24
Makefile.am
24
Makefile.am
@ -46,6 +46,7 @@ dist_man_MANS = \
|
|||||||
if BUILD_KILL
|
if BUILD_KILL
|
||||||
bin_PROGRAMS = kill
|
bin_PROGRAMS = kill
|
||||||
dist_man_MANS += kill.1
|
dist_man_MANS += kill.1
|
||||||
|
kill_SOURCES = skill.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if WITH_NCURSES
|
if WITH_NCURSES
|
||||||
@ -55,9 +56,9 @@ usrbin_exec_PROGRAMS += \
|
|||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
slabtop.1 \
|
slabtop.1 \
|
||||||
watch.1
|
watch.1
|
||||||
slabtop_SOURCES = slabtop.c $(top_srcdir)/lib/strutils.c
|
slabtop_SOURCES = slabtop.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||||
slabtop_LDADD = @NCURSES_LIBS@
|
slabtop_LDADD = @NCURSES_LIBS@
|
||||||
watch_SOURCES = watch.c $(top_srcdir)/lib/strutils.c
|
watch_SOURCES = watch.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||||
watch_LDADD = @WATCH_NCURSES_LIBS@
|
watch_LDADD = @WATCH_NCURSES_LIBS@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -65,18 +66,23 @@ if BUILD_SKILL
|
|||||||
usrbin_exec_PROGRAMS += \
|
usrbin_exec_PROGRAMS += \
|
||||||
skill \
|
skill \
|
||||||
snice
|
snice
|
||||||
skill_SOURCES = skill.c $(top_srcdir)/lib/strutils.c
|
skill_SOURCES = skill.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||||
snice_SOURCES = skill.c $(top_srcdir)/lib/strutils.c
|
snice_SOURCES = skill.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
skill.1 \
|
skill.1 \
|
||||||
snice.1
|
snice.1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
kill_SOURCES = skill.c $(top_srcdir)/lib/strutils.c
|
free_SOURCES = free.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||||
tload_SOURCES = tload.c $(top_srcdir)/lib/strutils.c
|
pgrep_SOURCES = pgrep.c $(top_srcdir)/lib/fileutils.c
|
||||||
pkill_SOURCES = pgrep.c
|
pkill_SOURCES = pgrep.c $(top_srcdir)/lib/fileutils.c
|
||||||
free_SOURCES = free.c $(top_srcdir)/lib/strutils.c
|
pmap_SOURCES = pmap.c $(top_srcdir)/lib/fileutils.c
|
||||||
vmstat_SOURCES = vmstat.c $(top_srcdir)/lib/strutils.c
|
pwdx_SOURCES = pwdx.c $(top_srcdir)/lib/fileutils.c
|
||||||
|
sysctl_SOURCES = sysctl.c $(top_srcdir)/lib/fileutils.c
|
||||||
|
tload_SOURCES = tload.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||||
|
uptime_SOURCES = uptime.c $(top_srcdir)/lib/fileutils.c
|
||||||
|
vmstat_SOURCES = vmstat.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||||
|
w_SOURCES = w.c $(top_srcdir)/lib/fileutils.c
|
||||||
|
|
||||||
sysconf_DATA = sysctl.conf
|
sysconf_DATA = sysctl.conf
|
||||||
|
|
||||||
|
2
free.c
2
free.c
@ -32,6 +32,7 @@
|
|||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
|
#include "fileutils.h"
|
||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -226,6 +227,7 @@ int main(int argc, char **argv)
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "bkmghlotc:s:V", longopts, NULL)) != -1)
|
while ((c = getopt_long(argc, argv, "bkmghlotc:s:V", longopts, NULL)) != -1)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
2
pgrep.c
2
pgrep.c
@ -42,6 +42,7 @@
|
|||||||
#define XALLOC_EXIT_CODE EXIT_FATAL
|
#define XALLOC_EXIT_CODE EXIT_FATAL
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
#include "proc/readproc.h"
|
#include "proc/readproc.h"
|
||||||
@ -791,6 +792,7 @@ int main (int argc, char **argv)
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
parse_opts (argc, argv);
|
parse_opts (argc, argv);
|
||||||
|
|
||||||
|
2
pmap.c
2
pmap.c
@ -31,6 +31,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "proc/escape.h"
|
#include "proc/escape.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
@ -426,6 +427,7 @@ int main(int argc, char **argv)
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
x_option = d_option = q_option = 0;
|
x_option = d_option = q_option = 0;
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ pscommand_SOURCES = \
|
|||||||
parser.c \
|
parser.c \
|
||||||
select.c \
|
select.c \
|
||||||
sortformat.c \
|
sortformat.c \
|
||||||
stacktrace.c
|
stacktrace.c \
|
||||||
|
$(top_srcdir)/lib/fileutils.c
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
HACKING \
|
HACKING \
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "../proc/version.h"
|
#include "../proc/version.h"
|
||||||
#include "../proc/wchan.h"
|
#include "../proc/wchan.h"
|
||||||
|
|
||||||
|
#include "../include/fileutils.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#ifndef SIGCHLD
|
#ifndef SIGCHLD
|
||||||
@ -531,6 +532,7 @@ static void fancy_spew(void){
|
|||||||
|
|
||||||
/***** no comment */
|
/***** no comment */
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
|
atexit(close_stdout);
|
||||||
myname = strrchr(*argv, '/');
|
myname = strrchr(*argv, '/');
|
||||||
if (myname) ++myname; else myname = *argv;
|
if (myname) ++myname; else myname = *argv;
|
||||||
|
|
||||||
|
2
pwdx.c
2
pwdx.c
@ -30,6 +30,7 @@
|
|||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
#include "fileutils.h"
|
||||||
|
|
||||||
static void __attribute__ ((__noreturn__)) usage(FILE * out)
|
static void __attribute__ ((__noreturn__)) usage(FILE * out)
|
||||||
{
|
{
|
||||||
@ -77,6 +78,7 @@ int main(int argc, char *argv[])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
|
while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
2
skill.c
2
skill.c
@ -35,6 +35,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
@ -375,6 +376,7 @@ static void __attribute__ ((__noreturn__))
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
kill_usage(stderr);
|
kill_usage(stderr);
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
#include "proc/slab.h"
|
#include "proc/slab.h"
|
||||||
@ -303,6 +304,7 @@ int main(int argc, char *argv[])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
sort_func = DEF_SORT_FUNC;
|
sort_func = DEF_SORT_FUNC;
|
||||||
|
|
||||||
|
2
sysctl.c
2
sysctl.c
@ -40,6 +40,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
#include "proc/procps.h"
|
#include "proc/procps.h"
|
||||||
@ -675,6 +676,7 @@ int main(int argc, char *argv[])
|
|||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
PrintName = true;
|
PrintName = true;
|
||||||
PrintNewline = true;
|
PrintNewline = true;
|
||||||
|
2
tload.c
2
tload.c
@ -27,6 +27,7 @@
|
|||||||
#include "proc/version.h"
|
#include "proc/version.h"
|
||||||
#include "proc/sysinfo.h"
|
#include "proc/sysinfo.h"
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
@ -117,6 +118,7 @@ int main(int argc, char **argv)
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
while ((opt =
|
while ((opt =
|
||||||
getopt_long(argc, argv, "s:d:Vh", longopts, NULL)) != -1)
|
getopt_long(argc, argv, "s:d:Vh", longopts, NULL)) != -1)
|
||||||
|
@ -13,7 +13,8 @@ top_SOURCES = \
|
|||||||
top.h \
|
top.h \
|
||||||
top.c \
|
top.c \
|
||||||
top_nls.h \
|
top_nls.h \
|
||||||
top_nls.c
|
top_nls.c \
|
||||||
|
$(top_srcdir)/lib/fileutils.c
|
||||||
|
|
||||||
dist_man_MANS = \
|
dist_man_MANS = \
|
||||||
top.1
|
top.1
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <values.h>
|
#include <values.h>
|
||||||
|
|
||||||
|
#include "../include/fileutils.h"
|
||||||
#include "../include/nls.h"
|
#include "../include/nls.h"
|
||||||
|
|
||||||
#include "../proc/devname.h"
|
#include "../proc/devname.h"
|
||||||
@ -3902,6 +3903,7 @@ static void frame_make (void) {
|
|||||||
* duh... */
|
* duh... */
|
||||||
int main (int dont_care_argc, char **argv) {
|
int main (int dont_care_argc, char **argv) {
|
||||||
(void)dont_care_argc;
|
(void)dont_care_argc;
|
||||||
|
atexit(close_stdout);
|
||||||
before(*argv);
|
before(*argv);
|
||||||
// +-------------+
|
// +-------------+
|
||||||
wins_stage_1(); // top (sic) slice
|
wins_stage_1(); // top (sic) slice
|
||||||
|
2
uptime.c
2
uptime.c
@ -23,6 +23,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "proc/whattime.h"
|
#include "proc/whattime.h"
|
||||||
#include "proc/version.h"
|
#include "proc/version.h"
|
||||||
@ -53,6 +54,7 @@ int main(int argc, char **argv)
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "hV", longopts, NULL)) != -1)
|
while ((c = getopt_long(argc, argv, "hV", longopts, NULL)) != -1)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
2
vmstat.c
2
vmstat.c
@ -45,6 +45,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
#include "proc/sysinfo.h"
|
#include "proc/sysinfo.h"
|
||||||
@ -725,6 +726,7 @@ int main(int argc, char *argv[])
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
while ((c =
|
while ((c =
|
||||||
getopt_long(argc, argv, "afmnsdDp:S:hV", longopts,
|
getopt_long(argc, argv, "afmnsdDp:S:hV", longopts,
|
||||||
|
2
w.c
2
w.c
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "proc/devname.h"
|
#include "proc/devname.h"
|
||||||
#include "proc/escape.h"
|
#include "proc/escape.h"
|
||||||
@ -356,6 +357,7 @@ int main(int argc, char **argv)
|
|||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
#ifndef W_SHOWFROM
|
#ifndef W_SHOWFROM
|
||||||
from = 0;
|
from = 0;
|
||||||
|
2
watch.c
2
watch.c
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "c.h"
|
#include "c.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "proc/procps.h"
|
#include "proc/procps.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
@ -588,6 +589,7 @@ int main(int argc, char *argv[])
|
|||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
atexit(close_stdout);
|
||||||
|
|
||||||
while ((optc =
|
while ((optc =
|
||||||
getopt_long(argc, argv, "+bced::ghn:pvtx", longopts, (int *)0))
|
getopt_long(argc, argv, "+bced::ghn:pvtx", longopts, (int *)0))
|
||||||
|
Loading…
Reference in New Issue
Block a user