From 16bb8d07c235e9ba35ff897be9a59e3cc7cbdc79 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 7 Mar 2026 22:16:12 +0100 Subject: Changed psend_command() --- FICS/utils.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'FICS') diff --git a/FICS/utils.c b/FICS/utils.c index 38c7a81..0b44afa 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -662,11 +662,16 @@ psend_command(int p, char *command, char *input) char tmp[MAX_LINE_SIZE]; int num; + if (command == NULL || strcmp(command, "") == 0) { + warnx("%s: error: no command", __func__); + return -1; + } + if (input) fp = popen(command, "w"); else fp = popen(command, "r"); - if (!fp) + if (fp == NULL) return -1; if (input) { @@ -679,8 +684,7 @@ psend_command(int p, char *command, char *input) } } - pclose(fp); - return 0; + return (pclose(fp) == -1 ? -1 : 0); } PUBLIC char * -- cgit v1.2.3