]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - gui.c
Always check the return value of mark_fd_nonblocking().
[paraslash.git] / gui.c
diff --git a/gui.c b/gui.c
index 2fddc2f8dbbf2674fae9613fcb8b99da616044ed..c335250fee77daccc61868963e6135a220337610 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1998-2007 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1998-2008 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -45,7 +45,7 @@ struct rb_entry {
        size_t len;
        int color;
 };
-void *bot_win_rb;
+struct ringbuffer *bot_win_rb;
 #define NUM_LINES(len) (1 + (len) / bot.cols)
 
 static unsigned scroll_position;
@@ -966,8 +966,15 @@ check_return:
  */
 static int send_output(void)
 {
+       int ret;
+
        if (command_pipe < 0)
                return 0;
+       ret = mark_fd_nonblocking(command_pipe);
+       if (ret < 0) {
+               close(command_pipe);
+               return ret;
+       }
        if (do_select(COMMAND_MODE) >= 0)
                PARA_INFO_LOG("%s", "command complete");
        else
@@ -979,7 +986,7 @@ static int send_output(void)
 static int client_cmd_cmdline(char *cmd)
 {
        int ret, fds[3] = {0, 1, 0};
-       char *c = make_message(BINDIR "/para_client %s", cmd);
+       char *c = make_message(BINDIR "/para_client -- %s", cmd);
 
        outputf(COLOR_COMMAND, "%s", c);
        print_in_bar(COLOR_MSG, "executing client command, hit any key to abort\n");
@@ -988,7 +995,6 @@ static int client_cmd_cmdline(char *cmd)
        if (ret < 0)
                return -1;
        command_pipe = fds[1];
-       mark_fd_nonblocking(command_pipe);
        return send_output();
 }
 
@@ -1004,7 +1010,6 @@ static int display_cmd(char *cmd)
        if (para_exec_cmdline_pid(&cmd_pid, cmd, fds) < 0)
                return -1;
        command_pipe = fds[1];
-       mark_fd_nonblocking(command_pipe);
        return send_output();
 }