sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
cdd2a8c360
commit
efb8854f4c
|
@ -34,6 +34,7 @@
|
|||
#include <sys/utsname.h>
|
||||
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
|
||||
static void __attribute__ ((__noreturn__)) usage(FILE * out)
|
||||
|
@ -61,6 +62,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
|
||||
switch (ch) {
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "strutils.h"
|
||||
#include "bitops.h"
|
||||
#include "path.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define _PATH_SYS_CPU "/sys/devices/system/cpu"
|
||||
#define _PATH_SYS_CPU_ONLINE _PATH_SYS_CPU "/online"
|
||||
|
@ -246,6 +247,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
maxcpus = get_max_number_of_cpus();
|
||||
if (maxcpus < 1)
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "linux_reboot.h"
|
||||
#include "nls.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
static void __attribute__ ((__noreturn__)) usage(FILE * out)
|
||||
{
|
||||
|
@ -37,6 +38,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
|
||||
switch (ch) {
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
#include "c.h"
|
||||
#include "cyclades.h"
|
||||
#include "closestream.h"
|
||||
#include "strutils.h"
|
||||
|
||||
#if 0
|
||||
|
@ -311,6 +312,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((i =
|
||||
getopt_long(argc, argv, "qs:S:t:T:gGi:Vh", longopts,
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "widechar.h"
|
||||
#include "writeall.h"
|
||||
#include "bitops.h"
|
||||
#include "closestream.h"
|
||||
|
||||
/* Close the log. Currently a NOP. */
|
||||
#define SYSLOG_ACTION_CLOSE 0
|
||||
|
@ -688,6 +689,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "CcDdEF:f:hkl:n:rs:TtuVx",
|
||||
longopts, NULL)) != -1) {
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#include "nls.h"
|
||||
#include "strutils.h"
|
||||
#include "c.h"
|
||||
|
||||
#include "closestream.h"
|
||||
|
||||
static void __attribute__((__noreturn__)) usage(FILE *out)
|
||||
{
|
||||
|
@ -104,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, "hVnpl:o:", longopts, NULL)) != -1) {
|
||||
switch(c) {
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "c.h"
|
||||
#include "nls.h"
|
||||
#include "strutils.h"
|
||||
#include "closestream.h"
|
||||
|
||||
static void __attribute__((__noreturn__)) usage(int ex)
|
||||
{
|
||||
|
@ -161,6 +162,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
if (argc < 2)
|
||||
usage(EX_USAGE);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "blkdev.h"
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
#include "c.h"
|
||||
|
||||
static int freeze_f(int fd)
|
||||
|
@ -68,6 +69,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "hfu", longopts, NULL)) != -1) {
|
||||
switch(c) {
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "nls.h"
|
||||
#include "strutils.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#ifndef FITRIM
|
||||
struct fstrim_range {
|
||||
|
@ -87,6 +88,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
memset(&range, 0, sizeof(range));
|
||||
range.len = ULLONG_MAX;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "c.h"
|
||||
#include "nls.h"
|
||||
#include "strutils.h"
|
||||
#include "closestream.h"
|
||||
|
||||
key_t create_key(void)
|
||||
{
|
||||
|
@ -98,6 +99,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while((opt = getopt_long(argc, argv, "hM:QS:p:Vh", longopts, NULL)) != -1) {
|
||||
switch(opt) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "c.h"
|
||||
#include "nls.h"
|
||||
#include "strutils.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#ifndef HAVE_UNION_SEMUN
|
||||
/* according to X/OPEN we have to define it ourselves */
|
||||
|
@ -316,6 +317,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
/* check to see if the command is being invoked in the old way if so
|
||||
* then remove argument list */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "c.h"
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
|
||||
/*
|
||||
* SHM_DEST and SHM_LOCKED are defined in kernel headers, but inside
|
||||
|
@ -162,6 +163,7 @@ int main (int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((opt = getopt_long(argc, argv, options, longopts, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "c.h"
|
||||
#include "nls.h"
|
||||
#include "strutils.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#ifndef N_GIGASET_M101
|
||||
# define N_GIGASET_M101 16
|
||||
|
@ -234,6 +235,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
/* parse options */
|
||||
progname = program_invocation_short_name;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "strutils.h"
|
||||
#include "loopdev.h"
|
||||
#include "xgetpass.h"
|
||||
#include "closestream.h"
|
||||
|
||||
enum {
|
||||
A_CREATE = 1, /* setup a new device */
|
||||
|
@ -217,6 +218,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
loopcxt_init(&lc, 0);
|
||||
loopcxt_enable_debug(&lc, getenv("LOOPDEV_DEBUG") ? TRUE : FALSE);
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "bitops.h"
|
||||
#include "tt.h"
|
||||
#include "path.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define CACHE_MAX 100
|
||||
|
||||
|
@ -1255,6 +1256,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "abce::hp::s:xV", longopts, NULL)) != -1) {
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "xgetpass.h"
|
||||
#include "exitcodes.h"
|
||||
#include "xalloc.h"
|
||||
#include "closestream.h"
|
||||
|
||||
/*** TODO: DOCS:
|
||||
*
|
||||
|
@ -701,6 +702,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
mnt_init_debug(0);
|
||||
cxt = mnt_new_context();
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "nls.h"
|
||||
#include "xalloc.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
static int quiet;
|
||||
|
||||
|
@ -147,6 +148,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
mnt_init_debug(0);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "c.h"
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define pivot_root(new_root,put_old) syscall(SYS_pivot_root,new_root,put_old)
|
||||
|
||||
|
@ -50,6 +51,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
|
||||
switch (ch) {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "xalloc.h"
|
||||
#include "strutils.h"
|
||||
#include "list.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#ifndef RLIMIT_RTTIME
|
||||
# define RLIMIT_RTTIME 15
|
||||
|
@ -513,6 +514,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
INIT_LIST_HEAD(&lims);
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
|
||||
#include "nls.h"
|
||||
#include "xalloc.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define S_LEN 128
|
||||
|
||||
|
@ -166,6 +167,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
proFile = defaultpro;
|
||||
mapFile = defaultmap;
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <errno.h>
|
||||
#include "nls.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
static int donice(int,int,int);
|
||||
|
||||
|
@ -86,6 +87,7 @@ main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "usleep.h"
|
||||
#include "strutils.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
/* constants from legacy PC/AT hardware */
|
||||
#define RTC_PF 0x40
|
||||
|
@ -285,7 +286,8 @@ static void suspend_system(const char *suspend)
|
|||
}
|
||||
|
||||
/* this executes after wake from suspend */
|
||||
fclose(f);
|
||||
if (close_stream(f))
|
||||
errx(EXIT_FAILURE, _("write error"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -394,6 +396,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((t = getopt_long(argc, argv, "ahd:lm:ns:t:uVv",
|
||||
long_options, NULL)) != EOF) {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <sys/utsname.h>
|
||||
#include "nls.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define set_pers(pers) ((long)syscall(SYS_personality, pers))
|
||||
|
||||
|
@ -251,6 +252,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
if (argc < 1)
|
||||
show_usage(_("Not enough arguments"));
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "c.h"
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
|
||||
static void __attribute__ ((__noreturn__)) usage(FILE * out)
|
||||
{
|
||||
|
@ -53,6 +54,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "+Vhc", longopts, NULL)) != -1)
|
||||
switch (ch) {
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "canonicalize.h"
|
||||
#include "xalloc.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define PATH_MKSWAP "/sbin/mkswap"
|
||||
|
||||
|
@ -890,6 +891,7 @@ main(int argc, char *argv[]) {
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
progname = program_invocation_short_name;
|
||||
if (!progname) {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "c.h"
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#ifndef MS_MOVE
|
||||
#define MS_MOVE 8192
|
||||
|
@ -194,6 +195,7 @@ static void __attribute__((__noreturn__)) usage(FILE *output)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *newroot, *init, **initargs;
|
||||
atexit(close_stdout);
|
||||
|
||||
if (argv[1] && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")))
|
||||
usage(stdout);
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "lp.h"
|
||||
#include "nls.h"
|
||||
#include "xalloc.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define EXIT_BAD_VALUE 3
|
||||
#define EXIT_LP_IO_ERR 4
|
||||
|
@ -142,6 +143,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
if (argc < 2)
|
||||
print_usage(stderr);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "env.h"
|
||||
#include "optutils.h"
|
||||
#include "exitcodes.h"
|
||||
#include "closestream.h"
|
||||
|
||||
static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__)),
|
||||
const char *filename, int line)
|
||||
|
@ -309,6 +310,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
mnt_init_debug(0);
|
||||
cxt = mnt_new_context();
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "nls.h"
|
||||
#include "c.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#ifndef CLONE_NEWSNS
|
||||
# define CLONE_NEWNS 0x00020000
|
||||
|
@ -91,6 +92,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_MESSAGES, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while((c = getopt_long(argc, argv, "hVmuin", longopts, NULL)) != -1) {
|
||||
switch(c) {
|
||||
|
|
Loading…
Reference in New Issue