goto repeat;
}
-/*
- * read from command pipe and print data to bot window
- */
-static void send_output(void)
+/* read from command pipe and print data to bot window */
+static void exec_and_display_cmd(const char *cmd)
{
- int ret;
+ int ret, fds[3] = {0, 1, 1};
- ret = mark_fd_nonblocking(command_fds[0]);
+ outputf(COLOR_COMMAND, "%s", cmd);
+ ret = para_exec_cmdline_pid(&cmd_pid, cmd, fds);
+ if (ret < 0)
+ return;
+ ret = mark_fd_nonblocking(fds[1]);
if (ret < 0)
goto fail;
- ret = mark_fd_nonblocking(command_fds[1]);
+ ret = mark_fd_nonblocking(fds[2]);
if (ret < 0)
goto fail;
+ command_fds[0] = fds[1];
+ command_fds[1] = fds[2];
if (do_select(COMMAND_MODE) >= 0)
PARA_INFO_LOG("command complete\n");
else
static void para_cmd(char *cmd)
{
- int ret, fds[3] = {0, 1, 1};
- char *c = make_message(BINDIR "/para_client -- %s", cmd);
+ char *c;
- outputf(COLOR_COMMAND, "%s", c);
print_in_bar(COLOR_MSG, "executing client command, hit any key to abort\n");
- ret = para_exec_cmdline_pid(&cmd_pid, c, fds);
+ c = make_message(BINDIR "/para_client -- %s", cmd);
+ exec_and_display_cmd(c);
free(c);
- if (ret < 0)
- return;
- command_fds[0] = fds[1];
- command_fds[1] = fds[2];
- send_output();
}
-/*
- * exec command and print output to bot win
- */
static void display_cmd(char *cmd)
{
- int fds[3] = {0, 1, 1};
-
print_in_bar(COLOR_MSG, "executing display command, hit any key to abort");
- outputf(COLOR_COMMAND, "%s", cmd);
- if (para_exec_cmdline_pid(&cmd_pid, cmd, fds) < 0)
- return;
- command_fds[0] = fds[1];
- command_fds[1] = fds[2];
- send_output();
+ exec_and_display_cmd(cmd);
}
/*