From 60ef885705932a682097ad2b9f2379282d814e79 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 6 May 2010 07:06:42 +0200 Subject: [PATCH] gui: Combine open_stat_pipe() and para_open_stat_pipe(). It is kind of pointless to have two functions for this. It was justified in the long ago when para_sdl_gui executed the same command. --- gui.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/gui.c b/gui.c index 8e2dee1c..fa1538b0 100644 --- a/gui.c +++ b/gui.c @@ -191,20 +191,6 @@ static struct gui_command command_list[] = { } }; -static int para_open_stat_pipe(char *cmd) -{ - int fds[3] = {0, 1, 0}; - pid_t pid; - int ret = para_exec_cmdline_pid(&pid, cmd, fds); - if (ret < 0) - return ret; - ret = mark_fd_nonblocking(fds[1]); - if (ret > 0) - return fds[1]; - close(fds[1]); - return ret; -} - static int find_cmd_byname(char *name) { int i; @@ -910,12 +896,21 @@ static void handle_signal(int sig) static int open_stat_pipe(void) { static int init = 1; + int ret, fds[3] = {0, 1, 0}; + pid_t pid; if (init) init = 0; else sleep(1); - return para_open_stat_pipe(conf.stat_cmd_arg); + ret = para_exec_cmdline_pid(&pid, conf.stat_cmd_arg, fds); + if (ret < 0) + return ret; + ret = mark_fd_nonblocking(fds[1]); + if (ret >= 0) + return fds[1]; + close(fds[1]); + return ret; } /* -- 2.30.2