chiark / gitweb /
prefork-interp: Have protocol_exchange return an error message
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 15 Aug 2022 16:09:11 +0000 (17:09 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Aug 2022 20:21:10 +0000 (21:21 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cprogs/prefork-interp.c

index 8e4b03cec19ffe9be2762682278c0b0167a5c8c8..91ab3cb9efbc9cbc27e9543ce597cbc418ffab17 100644 (file)
@@ -280,12 +280,12 @@ static bool was_eof(FILE *call_sock) {
   return feof(call_sock) || errno==ECONNRESET;
 }
 
-// Does protocol exchange.  Returns 0 if OK, -1 if peer was garbage.
-static int protocol_exchange(FILE *call_sock) {
+// Does protocol exchange.  Returns 0 if OK, error msg if peer was garbage.
+static const char *protocol_exchange(FILE *call_sock) {
   char ack;
   size_t sr = fread(&ack, sizeof(ack), 1, call_sock);
   if (sr != 1) {
-    if (was_eof(call_sock)) return -1;
+    if (was_eof(call_sock)) return "initial monitor process quit";
     diee("read() ack byte");
   }
   if (ack != '\n') die("got ack byte 0x%02x, not '\n'", ack);
@@ -316,7 +316,7 @@ static FILE *connect_existing(void) {
   call_sock = call_sock_from_fd(fd);
   fd = -1;
 
-  if (protocol_exchange(call_sock) < 0)
+  if (protocol_exchange(call_sock))
     goto x_garbage;
 
   return call_sock;