05ad79
From 214d0ef6ac63442c285dd5d9d54190c62faf50d7 Mon Sep 17 00:00:00 2001
05ad79
From: Karel Zak <kzak@redhat.com>
05ad79
Date: Mon, 16 Oct 2017 13:30:44 +0200
05ad79
Subject: [PATCH 133/135] script: use all-io to write
05ad79
05ad79
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1427500
05ad79
Signed-off-by: Karel Zak <kzak@redhat.com>
05ad79
---
05ad79
 term-utils/script.c | 12 ++++--------
05ad79
 1 file changed, 4 insertions(+), 8 deletions(-)
05ad79
05ad79
diff --git a/term-utils/script.c b/term-utils/script.c
05ad79
index 242b8154a..5840b600d 100644
05ad79
--- a/term-utils/script.c
05ad79
+++ b/term-utils/script.c
05ad79
@@ -62,6 +62,7 @@
05ad79
 #include "closestream.h"
05ad79
 #include "nls.h"
05ad79
 #include "c.h"
05ad79
+#include "all-io.h"
05ad79
 
05ad79
 #if defined(HAVE_LIBUTIL) && defined(HAVE_PTY_H)
05ad79
 # include <pty.h>
05ad79
@@ -301,8 +302,7 @@ doinput(void) {
05ad79
 
05ad79
 	while (die == 0) {
05ad79
 		if ((cc = read(STDIN_FILENO, ibuf, BUFSIZ)) > 0) {
05ad79
-			ssize_t wrt = write(master, ibuf, cc);
05ad79
-			if (wrt < 0) {
05ad79
+			if (write_all(master, ibuf, cc)) {
05ad79
 				warn (_("write failed"));
05ad79
 				fail();
05ad79
 			}
05ad79
@@ -355,8 +355,6 @@ dooutput(FILE *timingfd) {
05ad79
 	struct timeval tv;
05ad79
 	double oldtime=time(NULL), newtime;
05ad79
 	int flgs = 0;
05ad79
-	ssize_t wrt;
05ad79
-	ssize_t fwrt;
05ad79
 
05ad79
 	close(STDIN_FILENO);
05ad79
 #ifdef HAVE_LIBUTIL
05ad79
@@ -393,13 +391,11 @@ dooutput(FILE *timingfd) {
05ad79
 			fprintf(timingfd, "%f %zd\n", newtime - oldtime, cc);
05ad79
 			oldtime = newtime;
05ad79
 		}
05ad79
-		wrt = write(STDOUT_FILENO, obuf, cc);
05ad79
-		if (wrt < 0) {
05ad79
+		if (write_all(STDOUT_FILENO, obuf, cc)) {
05ad79
 			warn (_("write failed"));
05ad79
 			fail();
05ad79
 		}
05ad79
-		fwrt = fwrite(obuf, 1, cc, fscript);
05ad79
-		if (fwrt < cc) {
05ad79
+		if (fwrite_all(obuf, 1, cc, fscript)) {
05ad79
 			warn (_("cannot write script file"));
05ad79
 			fail();
05ad79
 		}
05ad79
-- 
05ad79
2.13.6
05ad79