version 1.202, 2017/07/12 09:24:17 |
version 1.203, 2017/07/12 10:04:51 |
|
|
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <fnmatch.h> |
#include <fnmatch.h> |
|
#include <signal.h> |
#include <stdint.h> |
#include <stdint.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
const char *ptr, *first, *home; |
const char *ptr, *first, *home; |
struct termios tio2; |
struct termios tio2; |
int i; |
int i; |
|
sigset_t set, oldset; |
|
|
if (wp->fd != -1) { |
if (wp->fd != -1) { |
bufferevent_free(wp->event); |
bufferevent_free(wp->event); |
|
|
ws.ws_col = screen_size_x(&wp->base); |
ws.ws_col = screen_size_x(&wp->base); |
ws.ws_row = screen_size_y(&wp->base); |
ws.ws_row = screen_size_y(&wp->base); |
|
|
wp->pid = fdforkpty(ptm_fd, &wp->fd, wp->tty, NULL, &ws); |
sigfillset(&set); |
switch (wp->pid) { |
sigprocmask(SIG_BLOCK, &set, &oldset); |
|
switch (wp->pid = fdforkpty(ptm_fd, &wp->fd, wp->tty, NULL, &ws)) { |
case -1: |
case -1: |
wp->fd = -1; |
wp->fd = -1; |
|
|
xasprintf(cause, "%s: %s", cmd, strerror(errno)); |
xasprintf(cause, "%s: %s", cmd, strerror(errno)); |
free(cmd); |
free(cmd); |
|
|
|
sigprocmask(SIG_SETMASK, &oldset, NULL); |
return (-1); |
return (-1); |
case 0: |
case 0: |
|
proc_clear_signals(server_proc); |
|
sigprocmask(SIG_SETMASK, &oldset, NULL); |
|
|
if (chdir(wp->cwd) != 0) { |
if (chdir(wp->cwd) != 0) { |
if ((home = find_home()) == NULL || chdir(home) != 0) |
if ((home = find_home()) == NULL || chdir(home) != 0) |
chdir("/"); |
chdir("/"); |
|
|
if (tcsetattr(STDIN_FILENO, TCSANOW, &tio2) != 0) |
if (tcsetattr(STDIN_FILENO, TCSANOW, &tio2) != 0) |
fatal("tcgetattr failed"); |
fatal("tcgetattr failed"); |
|
|
|
log_close(); |
closefrom(STDERR_FILENO + 1); |
closefrom(STDERR_FILENO + 1); |
|
|
if (path != NULL) |
if (path != NULL) |
|
|
environ_set(env, "TMUX_PANE", "%%%u", wp->id); |
environ_set(env, "TMUX_PANE", "%%%u", wp->id); |
environ_push(env); |
environ_push(env); |
|
|
proc_clear_signals(server_proc); |
|
log_close(); |
|
|
|
setenv("SHELL", wp->shell, 1); |
setenv("SHELL", wp->shell, 1); |
ptr = strrchr(wp->shell, '/'); |
ptr = strrchr(wp->shell, '/'); |
|
|
|
|
fatal("execl failed"); |
fatal("execl failed"); |
} |
} |
|
|
|
sigprocmask(SIG_SETMASK, &oldset, NULL); |
setblocking(wp->fd, 0); |
setblocking(wp->fd, 0); |
|
|
wp->event = bufferevent_new(wp->fd, window_pane_read_callback, NULL, |
wp->event = bufferevent_new(wp->fd, window_pane_read_callback, NULL, |