version 1.8, 2009/11/26 21:37:13 |
version 1.9, 2009/12/03 22:50:10 |
|
|
switch (fork()) { |
switch (fork()) { |
case -1: |
case -1: |
ctx->error(ctx, "fork error: %s", strerror(errno)); |
ctx->error(ctx, "fork error: %s", strerror(errno)); |
return (-1); |
return (-1); |
case 0: |
case 0: |
/* Child process. */ |
/* Child process. */ |
close(pipe_fd[0]); |
close(pipe_fd[0]); |
|
|
|
|
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, cmd_pipe_pane_error_callback, wp); |
NULL, NULL, cmd_pipe_pane_error_callback, wp); |
bufferevent_enable(wp->pipe_event, EV_WRITE); |
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) |
fatal("fcntl failed"); |
fatal("fcntl failed"); |
if (fcntl(wp->pipe_fd, F_SETFD, FD_CLOEXEC) == -1) |
if (fcntl(wp->pipe_fd, F_SETFD, FD_CLOEXEC) == -1) |
fatal("fcntl failed"); |
fatal("fcntl failed"); |
return (0); |
return (0); |
} |
} |
} |
} |