diff options
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/blkid.c | 2 | ||||
-rw-r--r-- | misc-utils/cal.c | 2 | ||||
-rw-r--r-- | misc-utils/ddate.c | 2 | ||||
-rw-r--r-- | misc-utils/findfs.c | 2 | ||||
-rw-r--r-- | misc-utils/findmnt.c | 2 | ||||
-rw-r--r-- | misc-utils/kill.c | 2 | ||||
-rw-r--r-- | misc-utils/logger.c | 2 | ||||
-rw-r--r-- | misc-utils/look.c | 2 | ||||
-rw-r--r-- | misc-utils/lsblk.c | 2 | ||||
-rw-r--r-- | misc-utils/lslocks.c | 2 | ||||
-rw-r--r-- | misc-utils/mcookie.c | 11 | ||||
-rw-r--r-- | misc-utils/namei.c | 2 | ||||
-rw-r--r-- | misc-utils/rename.c | 2 | ||||
-rw-r--r-- | misc-utils/uuidd.c | 2 | ||||
-rw-r--r-- | misc-utils/uuidgen.c | 2 | ||||
-rw-r--r-- | misc-utils/whereis.c | 2 | ||||
-rw-r--r-- | misc-utils/wipefs.c | 2 |
17 files changed, 35 insertions, 8 deletions
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c index 978661903..3793c524f 100644 --- a/misc-utils/blkid.c +++ b/misc-utils/blkid.c @@ -44,6 +44,7 @@ extern int optind; #define STRTOXX_EXIT_CODE 4 /* strtoxx_or_err() */ #include "strutils.h" +#include "closestream.h" const char *progname = "blkid"; @@ -691,6 +692,7 @@ int main(int argc, char **argv) uintmax_t offset = 0, size = 0; show[0] = NULL; + atexit(close_stdout); while ((c = getopt (argc, argv, "c:df:ghilL:n:ko:O:ps:S:t:u:U:w:v")) != EOF) switch (c) { diff --git a/misc-utils/cal.c b/misc-utils/cal.c index c9efdf074..918cbab09 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -67,6 +67,7 @@ #include <errno.h> #include "c.h" +#include "closestream.h" #include "nls.h" #include "mbsalign.h" #include "strutils.h" @@ -278,6 +279,7 @@ main(int argc, char **argv) { setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); #if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW) || defined(HAVE_LIBTERMCAP) if ((term = getenv("TERM"))) { diff --git a/misc-utils/ddate.c b/misc-utils/ddate.c index 323cb9e2d..c0b4ce41d 100644 --- a/misc-utils/ddate.c +++ b/misc-utils/ddate.c @@ -63,6 +63,7 @@ #include <stdio.h> #include "nls.h" +#include "closestream.h" #include "c.h" #ifndef __GNUC__ @@ -169,6 +170,7 @@ main (int argc, char *argv[]) { setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); srandom(time(NULL)); /* do args here */ diff --git a/misc-utils/findfs.c b/misc-utils/findfs.c index 761c6e91f..bc4a84313 100644 --- a/misc-utils/findfs.c +++ b/misc-utils/findfs.c @@ -12,6 +12,7 @@ #include <blkid.h> #include "nls.h" +#include "closestream.h" #include "c.h" static void __attribute__((__noreturn__)) usage(int rc) @@ -35,6 +36,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); if (argc != 2) /* we return '2' for backward compatibility diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index fe91abb5f..172f38915 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -37,6 +37,7 @@ #include "pathnames.h" #include "nls.h" +#include "closestream.h" #include "c.h" #include "tt.h" #include "strutils.h" @@ -991,6 +992,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); /* default output format */ tt_flags |= TT_FL_TREE; diff --git a/misc-utils/kill.c b/misc-utils/kill.c index 15bb47051..dc024924c 100644 --- a/misc-utils/kill.c +++ b/misc-utils/kill.c @@ -53,6 +53,7 @@ #include "c.h" #include "kill.h" #include "nls.h" +#include "closestream.h" #include "strutils.h" struct signv { @@ -172,6 +173,7 @@ int main (int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); numsig = SIGTERM; do_pid = (! strcmp (progname, "pid")); /* Yecch */ diff --git a/misc-utils/logger.c b/misc-utils/logger.c index c89fca70a..e3b67d2a2 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -52,6 +52,7 @@ #include <getopt.h> #include "c.h" +#include "closestream.h" #include "nls.h" #include "strutils.h" @@ -188,6 +189,7 @@ main(int argc, char **argv) { setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); tag = NULL; pri = LOG_NOTICE; diff --git a/misc-utils/look.c b/misc-utils/look.c index 3d9623bfb..de231c96e 100644 --- a/misc-utils/look.c +++ b/misc-utils/look.c @@ -60,6 +60,7 @@ #include "nls.h" #include "xalloc.h" #include "pathnames.h" +#include "closestream.h" #define EQUAL 0 #define GREATER 1 @@ -99,6 +100,7 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); setlocale(LC_ALL, ""); diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 76356efbb..22c8e82d2 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -58,6 +58,7 @@ #include "strutils.h" #include "at.h" #include "sysfs.h" +#include "closestream.h" /* column IDs */ enum { @@ -1186,6 +1187,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); lsblk = &_ls; memset(lsblk, 0, sizeof(*lsblk)); diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c index 0abc2a4bf..f5390dcee 100644 --- a/misc-utils/lslocks.c +++ b/misc-utils/lslocks.c @@ -40,6 +40,7 @@ #include "at.h" #include "strutils.h" #include "c.h" +#include "closestream.h" /* column IDs */ enum { @@ -515,6 +516,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "p:o:nruhV", long_opts, NULL)) != -1) { diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c index 5bef4c541..b10f5c6fa 100644 --- a/misc-utils/mcookie.c +++ b/misc-utils/mcookie.c @@ -21,6 +21,8 @@ #include "c.h" #include "md5.h" #include "nls.h" +#include "closestream.h" + #include <fcntl.h> #include <getopt.h> #include <stddef.h> @@ -102,6 +104,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "f:vVh", longopts, NULL)) != -1) @@ -183,13 +186,5 @@ int main(int argc, char **argv) printf("%02x", digest[i]); putchar('\n'); - /* - * The following is important for cases like disk full, - * so shell scripts can bomb out properly rather than - * think they succeeded. - */ - if (fflush(stdout) < 0 || fclose(stdout) < 0) - return EXIT_FAILURE; - return EXIT_SUCCESS; } diff --git a/misc-utils/namei.c b/misc-utils/namei.c index e53b4c9a4..9b8ede901 100644 --- a/misc-utils/namei.c +++ b/misc-utils/namei.c @@ -38,6 +38,7 @@ #include "nls.h" #include "widechar.h" #include "strutils.h" +#include "closestream.h" #ifndef MAXSYMLINKS #define MAXSYMLINKS 256 @@ -448,6 +449,7 @@ main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "hVlmnovx", longopts, NULL)) != -1) { switch(c) { diff --git a/misc-utils/rename.c b/misc-utils/rename.c index f7c88cdaa..b17e03bb1 100644 --- a/misc-utils/rename.c +++ b/misc-utils/rename.c @@ -22,6 +22,7 @@ for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done #include "nls.h" #include "xalloc.h" #include "c.h" +#include "closestream.h" static int do_rename(char *from, char *to, char *s, int verbose) { @@ -89,6 +90,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "vVh", longopts, NULL)) != -1) switch (c) { diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c index 492ae4d03..7c19615b5 100644 --- a/misc-utils/uuidd.c +++ b/misc-utils/uuidd.c @@ -35,6 +35,7 @@ extern int optind; #include "uuidd.h" #include "writeall.h" +#include "closestream.h" #include "nls.h" #ifdef __GNUC__ @@ -455,6 +456,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "p:s:T:krtn:dqVh", longopts, diff --git a/misc-utils/uuidgen.c b/misc-utils/uuidgen.c index 2a98bc8be..219be8b62 100644 --- a/misc-utils/uuidgen.c +++ b/misc-utils/uuidgen.c @@ -24,6 +24,7 @@ extern int optind; #include "uuid.h" #include "nls.h" #include "c.h" +#include "closestream.h" #define DO_TYPE_TIME 1 #define DO_TYPE_RANDOM 2 @@ -62,6 +63,7 @@ main (int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "rtVh", longopts, NULL)) != -1) switch (c) { diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index 4a123f1a7..6807b8a68 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -53,6 +53,7 @@ #include "xalloc.h" #include "nls.h" #include "c.h" +#include "closestream.h" static char *bindirs[] = { "/bin", @@ -417,6 +418,7 @@ main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); argc--, argv++; if (argc == 0) diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index bd20997a1..a9d74f043 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -38,6 +38,7 @@ #include "writeall.h" #include "match.h" #include "c.h" +#include "closestream.h" struct wipe_desc { loff_t offset; /* magic string offset */ @@ -391,6 +392,7 @@ main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "ahno:pqt:V", longopts, NULL)) != -1) { switch(c) { |