From b68d0b893acb7887d5fadc696ac6683131c69794 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Debian Linux)" <rob@synchro.net>
Date: Mon, 27 Mar 2023 18:04:25 -0700
Subject: [PATCH] Detect user abort (Ctrl-C) and exit before posting the
 poll-msg

---
 exec/postpoll.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/exec/postpoll.js b/exec/postpoll.js
index 1d8deb96c6..f31a0b83d5 100644
--- a/exec/postpoll.js
+++ b/exec/postpoll.js
@@ -50,12 +50,16 @@ if(!(poll.subject = prompt("Poll question")))
 
 var comment;
 while(comment = prompt("Comment [done]")) poll.field_list.push({ type: SMB_COMMENT, data: comment});
+if(js.global.console && console.aborted)
+	exit(1);
 
 var count=0;
 var answer;
 while(count < MSG_POLL_MAX_ANSWERS && (answer = prompt("Answer "+ (++count) + " [done]")))
 	poll.field_list.push({ type: SMB_POLL_ANSWER, data: answer});
 
+if(js.global.console && console.aborted)
+	exit(1);
 print();
 print("Results Visibility:");
 print("0 = voters only (and pollster)");
@@ -63,6 +67,9 @@ print("1 = everyone always");
 print("2 = everyone once poll is closed (and pollster)");
 print("3 = pollster only");
 var results = parseInt(prompt("Results"));
+if(js.global.console && console.aborted)
+	exit(1);
+
 poll.auxattr = results << 30;
 if(js.global.bbs) {
 	poll.from = user.alias;
-- 
GitLab