From 4277f3654c089ed0409ac6699e05b7f50f5ec3d4 Mon Sep 17 00:00:00 2001
From: David Bigagli <david@schedmd.com>
Date: Thu, 17 Jan 2013 09:54:19 -0800
Subject: [PATCH] sacctmgr: terminate sacctmgr on EOF if readline function
 missing

---
 src/sacctmgr/sacctmgr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/sacctmgr/sacctmgr.c b/src/sacctmgr/sacctmgr.c
index b5b813f0863..f2225a9c965 100644
--- a/src/sacctmgr/sacctmgr.c
+++ b/src/sacctmgr/sacctmgr.c
@@ -256,9 +256,10 @@ static char *_getline(const char *prompt)
 	int len;
 	printf("%s", prompt);
 
-	/* we only set this here to avoid a warning.  We throw it away
-	   later. */
+	/* Set "line" here to avoid a warning and discard it away later. */
 	line = fgets(buf, 4096, stdin);
+	if (line == NULL)
+		return NULL;
 	len = strlen(buf);
 	if ((len > 0) && (buf[len-1] == '\n'))
 		buf[len-1] = '\0';
-- 
GitLab