[BACK]Return to cmd-pipe-pane.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/cmd-pipe-pane.c between version 1.3 and 1.4

version 1.3, 2009/11/04 20:50:11 version 1.4, 2009/11/04 22:02:38
Line 17 
Line 17 
  */   */
   
 #include <sys/types.h>  #include <sys/types.h>
   #include <sys/socket.h>
   
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
Line 32 
Line 33 
   
 int     cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *);  int     cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *);
   
   void    cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
   
 const struct cmd_entry cmd_pipe_pane_entry = {  const struct cmd_entry cmd_pipe_pane_entry = {
         "pipe-pane", "pipep",          "pipe-pane", "pipep",
         CMD_TARGET_PANE_USAGE "[-o] [command]",          CMD_TARGET_PANE_USAGE "[-o] [command]",
Line 56 
Line 59 
         /* Destroy the old pipe. */          /* Destroy the old pipe. */
         old_fd = wp->pipe_fd;          old_fd = wp->pipe_fd;
         if (wp->pipe_fd != -1) {          if (wp->pipe_fd != -1) {
                 buffer_destroy(wp->pipe_buf);                  bufferevent_free(wp->pipe_event);
                 close(wp->pipe_fd);                  close(wp->pipe_fd);
                 wp->pipe_fd = -1;                  wp->pipe_fd = -1;
         }          }
Line 75 
Line 78 
                 return (0);                  return (0);
   
         /* Open the new pipe. */          /* Open the new pipe. */
         if (pipe(pipe_fd) != 0) {          if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
                 ctx->error(ctx, "pipe error: %s", strerror(errno));                  ctx->error(ctx, "socketpair error: %s", strerror(errno));
                 return (-1);                  return (-1);
         }          }
   
Line 110 
Line 113 
                 close(pipe_fd[1]);                  close(pipe_fd[1]);
   
                 wp->pipe_fd = pipe_fd[0];                  wp->pipe_fd = pipe_fd[0];
                 wp->pipe_buf = buffer_create(BUFSIZ);  
                 wp->pipe_off = BUFFER_USED(wp->in);                  wp->pipe_off = BUFFER_USED(wp->in);
   
                   wp->pipe_event = bufferevent_new(wp->pipe_fd,
                       NULL, NULL, cmd_pipe_pane_error_callback, wp);
                   bufferevent_enable(wp->pipe_event, EV_WRITE);
   
                 if ((mode = fcntl(wp->pipe_fd, F_GETFL)) == -1)                  if ((mode = fcntl(wp->pipe_fd, F_GETFL)) == -1)
                         fatal("fcntl failed");                          fatal("fcntl failed");
                 if (fcntl(wp->pipe_fd, F_SETFL, mode|O_NONBLOCK) == -1)                  if (fcntl(wp->pipe_fd, F_SETFL, mode|O_NONBLOCK) == -1)
Line 123 
Line 129 
         }          }
   
         return (0);          return (0);
   }
   
   void
   cmd_pipe_pane_error_callback(
       unused struct bufferevent *bufev, unused short what, void *data)
   {
           struct window_pane      *wp = data;
   
           bufferevent_free(wp->pipe_event);
           close(wp->pipe_fd);
           wp->pipe_fd = -1;
 }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4