diff --git a/NT/tools/sprshd b/NT/tools/sprshd
index c7d9e5c26f428a012e7f2adf749c9d441d743456..e9c83ba5f0fb033fcf887e447005ecf082483996 100755
--- a/NT/tools/sprshd
+++ b/NT/tools/sprshd
@@ -1,4 +1,5 @@
 #!/usr/local/bin/pike
+/* -*- Pike -*- */
 
 inherit Stdio.Port;
 
@@ -273,7 +274,13 @@ void handle_incoming_connection(object(Stdio.File) io)
 	}
 	
 	io->write(sprintf("%4c",0));
-	io->write(sprintf("%4c",p->wait()));
+	int code;
+	if (catch { code = p->wait(); }) {
+	  // wait() failed.
+	  io->write(sprintf("%4c", -1));
+	} else {
+	  io->write(sprintf("%4c", code));
+	}
       }else{
 	werror("dir=%s\n",dir);
 	werror(master()->describe_backtrace(err));