From 6c26b57af3fcc6c32679117a4817c374ca5e9a6a Mon Sep 17 00:00:00 2001
From: Petr Baudis <pasky@ucw.cz>
Date: Thu, 1 Mar 2012 03:39:18 +0100
Subject: [PATCH] compctl: Print 'Unexpected hangup' if no reply is received

---
 compctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/compctl.c b/compctl.c
index 684f162..093bb88 100644
--- a/compctl.c
+++ b/compctl.c
@@ -63,7 +63,7 @@ run(int argc, char *argv[])
 	fgets(line, sizeof(line), f);
 	fclose(f);
 	if (line[0] != '1') {
-		fputs(line, stderr);
+		fputs(*line ? line : "unexpected hangup\n", stderr);
 		return EXIT_FAILURE;
 	}
 
@@ -96,7 +96,7 @@ stop(pid_t pid)
 	fgets(line, sizeof(line), f);
 	fclose(f);
 	if (line[0] != '1') {
-		fputs(line, stderr);
+		fputs(*line ? line : "unexpected hangup\n", stderr);
 		exit(EXIT_FAILURE);
 	}
 }
@@ -110,7 +110,7 @@ stop_all(void)
 	fgets(line, sizeof(line), f);
 	fclose(f);
 	if (line[0] != '1') {
-		fputs(line, stderr);
+		fputs(*line ? line : "unexpected hangup\n", stderr);
 		exit(EXIT_FAILURE);
 	}
 	fputs(line + 2, stdout);
@@ -126,7 +126,7 @@ limit_mem(size_t limit)
 	fclose(f);
 	if (line[0] != '1') {
 		/* TODO: Error message postprocessing. */
-		fputs(line, stderr);
+		fputs(*line ? line : "unexpected hangup\n", stderr);
 		exit(EXIT_FAILURE);
 	}
 }
-- 
GitLab