cdown / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0133-script-use-all-io-to-write.patch

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