version 1.42, 2017/05/01 12:20:55 |
version 1.43, 2017/07/03 08:16:03 |
|
|
|
|
static enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmdq_item *); |
static enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmdq_item *); |
|
|
|
static void cmd_pipe_pane_write_callback(struct bufferevent *, void *); |
static void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *); |
static 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 = { |
|
|
bufferevent_free(wp->pipe_event); |
bufferevent_free(wp->pipe_event); |
close(wp->pipe_fd); |
close(wp->pipe_fd); |
wp->pipe_fd = -1; |
wp->pipe_fd = -1; |
|
|
|
if (window_pane_destroy_ready(wp)) { |
|
server_destroy_pane(wp, 1); |
|
return (CMD_RETURN_NORMAL); |
|
} |
} |
} |
|
|
/* If no pipe command, that is enough. */ |
/* If no pipe command, that is enough. */ |
|
|
wp->pipe_fd = pipe_fd[0]; |
wp->pipe_fd = pipe_fd[0]; |
wp->pipe_off = EVBUFFER_LENGTH(wp->event->input); |
wp->pipe_off = EVBUFFER_LENGTH(wp->event->input); |
|
|
wp->pipe_event = bufferevent_new(wp->pipe_fd, |
wp->pipe_event = bufferevent_new(wp->pipe_fd, NULL, |
NULL, NULL, cmd_pipe_pane_error_callback, wp); |
cmd_pipe_pane_write_callback, cmd_pipe_pane_error_callback, |
|
wp); |
bufferevent_enable(wp->pipe_event, EV_WRITE); |
bufferevent_enable(wp->pipe_event, EV_WRITE); |
|
|
setblocking(wp->pipe_fd, 0); |
setblocking(wp->pipe_fd, 0); |
|
|
} |
} |
|
|
static void |
static void |
|
cmd_pipe_pane_write_callback(__unused struct bufferevent *bufev, void *data) |
|
{ |
|
struct window_pane *wp = data; |
|
|
|
log_debug("%%%u pipe empty", wp->id); |
|
if (window_pane_destroy_ready(wp)) |
|
server_destroy_pane(wp, 1); |
|
} |
|
|
|
static void |
cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev, |
cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev, |
__unused short what, void *data) |
__unused short what, void *data) |
{ |
{ |
struct window_pane *wp = data; |
struct window_pane *wp = data; |
|
|
|
log_debug("%%%u pipe error", wp->id); |
|
|
bufferevent_free(wp->pipe_event); |
bufferevent_free(wp->pipe_event); |
close(wp->pipe_fd); |
close(wp->pipe_fd); |
wp->pipe_fd = -1; |
wp->pipe_fd = -1; |
|
|
|
if (window_pane_destroy_ready(wp)) |
|
server_destroy_pane(wp, 1); |
} |
} |