commit ead4ff023e798a78b626a3fb958f2a8ddf190a59
parent 15c6a4dbb0a8ce4eecfc6f284711378c7f4199ee
Author: kocotian <kocotian@kocotian.pl>
Date: Sun, 6 Dec 2020 22:53:37 +0100
better termination, no blank outputs
Diffstat:
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/nmps.c b/nmps.c
@@ -14,7 +14,7 @@
#include "http.h"
#include "util.c"
-#define VERSION "a0.3.5"
+#define VERSION "a0.3.6"
extern void herror(const char *s);
@@ -79,11 +79,12 @@ command(char *command, char *args, char *host, char *port, char *beforeOutput)
++truncbuf;
}
}
- printf("%s%s%c", beforeOutput, truncbuf,
- buffer[reqsize - 1] == '\n' || buffer[reqsize - 1]
- == 030 /* ASCII 030 on the end simply means:
- PLZ DON'T INSERT ENDL ON THE END!!1!1!!1 */
- ? '\0' : '\n');
+ if (strlen(truncbuf))
+ printf("%s%s%c", beforeOutput, truncbuf,
+ buffer[reqsize - 1] == '\n' || buffer[reqsize - 1]
+ == 030 /* ASCII 030 on the end simply means:
+ PLZ DON'T INSERT ENDL ON THE END!!1!1!!1 */
+ ? '\0' : '\n');
if (exitAfter) {
if (getpid() != parentpid)
@@ -286,7 +287,8 @@ sighandler(int signo)
break;
case SIGTERM:
if (getpid() == parentpid)
- kill(eventpid, SIGKILL);
+ kill(eventpid, SIGTERM);
+ puts("Connection closed");
exit(0);
break;
}