static unsigned scroll_position;
-static int external_cmd_died, curses_active;
-static pid_t external_cmd_pid;
+static int cmd_died, curses_active;
+static pid_t cmd_pid;
static int command_pipe = -1;
static int audiod_pipe = -1;
pid = para_reap_child();
if (pid <= 0)
return;
- if (pid == external_cmd_pid) {
- external_cmd_pid = 0;
- external_cmd_died = 1;
+ if (pid == cmd_pid) {
+ cmd_pid = 0;
+ cmd_died = 1;
}
goto reap_next_child;
}
*
* EXTERNAL_MODE: Check only signal pipe. Used when an external command
* is running. During that thime curses is disabled. Returns when
- * external_cmd_pid == 0.
+ * cmd_pid == 0.
*/
static int do_select(int mode)
{
if (cp_numread <= 0)
cbo = 0;
wrefresh(bot.win);
+ ret = wgetch(top.win);
+ if (ret != ERR && ret != KEY_RESIZE) {
+ if (command_pipe) {
+ close(command_pipe);
+ command_pipe = -1;
+ }
+ if (cmd_pid)
+ kill(cmd_pid, SIGTERM);
+ return -1;
+ }
break;
case GETCH_MODE:
ret = wgetch(top.win);
return ret;
break;
case EXTERNAL_MODE:
- if (external_cmd_died) {
- external_cmd_died = 0;
+ if (cmd_died) {
+ cmd_died = 0;
return 0;
}
}
static int client_cmd_cmdline(char *cmd)
{
- pid_t pid;
int ret, fds[3] = {0, 1, 0};
char *c = make_message(BINDIR "/para_client %s", cmd);
outputf(COLOR_COMMAND, "%s", c);
- print_in_bar(COLOR_MSG, "executing client command, hit q to abort\n");
- ret = para_exec_cmdline_pid(&pid, c, fds);
+ print_in_bar(COLOR_MSG, "executing client command, hit any key to abort\n");
+ ret = para_exec_cmdline_pid(&cmd_pid, c, fds);
free(c);
if (ret < 0)
return -1;
*/
static int display_cmd(char *cmd)
{
- pid_t pid;
int fds[3] = {0, 1, 0};
- print_in_bar(COLOR_MSG, "executing display command, hit q to abort");
+ print_in_bar(COLOR_MSG, "executing display command, hit any key to abort");
outputf(COLOR_COMMAND, "%s", cmd);
- if (para_exec_cmdline_pid(&pid, cmd, fds) < 0)
+ if (para_exec_cmdline_pid(&cmd_pid, cmd, fds) < 0)
return -1;
command_pipe = fds[1];
return send_output();
{
int fds[3] = {-1, -1, -1};
- if (external_cmd_pid)
+ if (cmd_pid)
return -1;
shutdown_curses();
- para_exec_cmdline_pid(&external_cmd_pid, cmd, fds);
+ para_exec_cmdline_pid(&cmd_pid, cmd, fds);
+ cmd_died = 0;
do_select(EXTERNAL_MODE);
init_curses();
return 0;