From: Andre Noll <maan@systemlinux.org>
Date: Tue, 13 Mar 2012 21:30:34 +0000 (+0100)
Subject: gui: Check return value of para_exec_cmdline_pid().
X-Git-Tag: v0.4.10~1^2~1
X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=d0d27cfa56d05eaa0e5567c75adfe606eab2957e;p=paraslash.git

gui: Check return value of para_exec_cmdline_pid().

external_cmd() calls this function to execute the given command.
However, as para_exec_cmdline_pid() may fail, e.g. because the
underlying call to fork() failed due to hitting the RLIMIT_NPROC
resource limit, we must check the return value. The other two command
dispatchers got this right, but external_cmd() did not.
---

diff --git a/gui.c b/gui.c
index 48d4b51b..2ed66be7 100644
--- a/gui.c
+++ b/gui.c
@@ -1112,7 +1112,8 @@ static void external_cmd(char *cmd)
 	if (cmd_pid)
 		return;
 	shutdown_curses();
-	para_exec_cmdline_pid(&cmd_pid, cmd, fds);
+	if (para_exec_cmdline_pid(&cmd_pid, cmd, fds) < 0)
+		return;
 	cmd_died = 0;
 	do_select(EXTERNAL_MODE);
 	init_curses();