term-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
b87cbe8486
commit
cdd2a8c360
|
@ -54,6 +54,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
#include "c.h"
|
||||
|
||||
|
@ -88,6 +90,7 @@ int main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
static const struct option longopts[] = {
|
||||
{ "verbose", no_argument, 0, 'v' },
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include <locale.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
#include "c.h"
|
||||
|
||||
|
@ -180,6 +181,7 @@ main(int argc, char **argv) {
|
|||
setlocale(LC_NUMERIC, "C"); /* see comment above */
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "ac:efqt::Vh", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
|
@ -283,7 +285,8 @@ main(int argc, char **argv) {
|
|||
}
|
||||
doinput();
|
||||
|
||||
fclose(timingfd);
|
||||
if (close_stream(timingfd) != 0)
|
||||
errx(EXIT_FAILURE, _("write error"));
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -292,7 +295,8 @@ doinput(void) {
|
|||
ssize_t cc;
|
||||
char ibuf[BUFSIZ];
|
||||
|
||||
fclose(fscript);
|
||||
if (close_stream(fscript) != 0)
|
||||
errx(EXIT_FAILURE, _("write error"));
|
||||
|
||||
while (die == 0) {
|
||||
if ((cc = read(STDIN_FILENO, ibuf, BUFSIZ)) > 0) {
|
||||
|
@ -404,6 +408,8 @@ dooutput(FILE *timingfd) {
|
|||
|
||||
if (flgs)
|
||||
fcntl(master, F_SETFL, flgs);
|
||||
if (close_stream(timingfd) != 0)
|
||||
errx(EXIT_FAILURE, _("write error"));
|
||||
done();
|
||||
}
|
||||
|
||||
|
@ -423,7 +429,8 @@ doshell(void) {
|
|||
|
||||
getslave();
|
||||
close(master);
|
||||
fclose(fscript);
|
||||
if (close_stream(fscript) != 0)
|
||||
errx(EXIT_FAILURE, _("write error"));
|
||||
dup2(slave, STDIN_FILENO);
|
||||
dup2(slave, STDOUT_FILENO);
|
||||
dup2(slave, STDERR_FILENO);
|
||||
|
@ -484,7 +491,8 @@ done(void) {
|
|||
my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
|
||||
fprintf(fscript, _("\nScript done on %s"), buf);
|
||||
}
|
||||
fclose(fscript);
|
||||
if (close_stream(fscript) != 0)
|
||||
errx(EXIT_FAILURE, _("write error"));
|
||||
close(master);
|
||||
|
||||
master = -1;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
#include "c.h"
|
||||
|
||||
|
@ -153,6 +154,7 @@ main(int argc, char *argv[])
|
|||
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "t:s:d:Vh", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
|
|
|
@ -121,6 +121,7 @@
|
|||
#include "c.h"
|
||||
#include "xalloc.h"
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#if __GNU_LIBRARY__ < 5
|
||||
#ifndef __alpha__
|
||||
|
@ -1113,7 +1114,8 @@ perform_sequence(int vcterm) {
|
|||
err(EXIT_DUMPFILE, _("can not open dump file %s for output"),
|
||||
opt_sn_name);
|
||||
screendump(opt_sn_num, F);
|
||||
fclose(F);
|
||||
if (close_stream(F) != 0)
|
||||
errx(EXIT_FAILURE, _("write error"));
|
||||
}
|
||||
|
||||
/* -msg [on|off]. */
|
||||
|
@ -1225,6 +1227,7 @@ main(int argc, char **argv) {
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
if (argc < 2)
|
||||
bad_arg = TRUE;
|
||||
|
|
|
@ -51,8 +51,9 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "nls.h"
|
||||
|
||||
#include "nls.h"
|
||||
#include "closestream.h"
|
||||
#include "pathnames.h"
|
||||
#include "ttymsg.h"
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include "carefulputc.h"
|
||||
#include "c.h"
|
||||
#include "fileutils.h"
|
||||
#include "closestream.h"
|
||||
|
||||
#define IGNOREUSER "sleeper"
|
||||
#define WRITE_TIME_OUT 300 /* in seconds */
|
||||
|
@ -114,6 +115,7 @@ main(int argc, char **argv) {
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
static const struct option longopts[] = {
|
||||
{ "nobanner", no_argument, 0, 'n' },
|
||||
|
@ -281,6 +283,7 @@ makemsg(char *fname, size_t *mbufsize, int print_banner)
|
|||
if (fread(mbuf, 1, *mbufsize, fp) != *mbufsize)
|
||||
err(EXIT_FAILURE, _("fread failed"));
|
||||
|
||||
fclose(fp);
|
||||
if (close_stream(fp) != 0)
|
||||
errx(EXIT_FAILURE, _("write error"));
|
||||
return mbuf;
|
||||
}
|
||||
|
|
|
@ -59,8 +59,10 @@
|
|||
#include <paths.h>
|
||||
#include <asm/param.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "c.h"
|
||||
#include "carefulputc.h"
|
||||
#include "closestream.h"
|
||||
#include "nls.h"
|
||||
|
||||
static void __attribute__ ((__noreturn__)) usage(FILE * out);
|
||||
|
@ -103,6 +105,7 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
|
||||
switch (c) {
|
||||
|
|
Loading…
Reference in New Issue