version 1.98, 2013/10/10 11:59:23 |
version 1.99, 2013/10/10 12:26:37 |
|
|
|
|
struct window * |
struct window * |
window_create(const char *name, const char *cmd, const char *shell, |
window_create(const char *name, const char *cmd, const char *shell, |
const char *cwd, struct environ *env, struct termios *tio, |
int cwd, struct environ *env, struct termios *tio, |
u_int sx, u_int sy, u_int hlimit, char **cause) |
u_int sx, u_int sy, u_int hlimit, char **cause) |
{ |
{ |
struct window *w; |
struct window *w; |
|
|
|
|
wp->cmd = NULL; |
wp->cmd = NULL; |
wp->shell = NULL; |
wp->shell = NULL; |
wp->cwd = NULL; |
wp->cwd = -1; |
|
|
wp->fd = -1; |
wp->fd = -1; |
wp->event = NULL; |
wp->event = NULL; |
|
|
|
|
RB_REMOVE(window_pane_tree, &all_window_panes, wp); |
RB_REMOVE(window_pane_tree, &all_window_panes, wp); |
|
|
free(wp->cwd); |
close(wp->cwd); |
free(wp->shell); |
free(wp->shell); |
free(wp->cmd); |
free(wp->cmd); |
free(wp); |
free(wp); |
|
|
|
|
int |
int |
window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell, |
window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell, |
const char *cwd, struct environ *env, struct termios *tio, char **cause) |
int cwd, struct environ *env, struct termios *tio, char **cause) |
{ |
{ |
struct winsize ws; |
struct winsize ws; |
char *argv0, paneid[16]; |
char *argv0, paneid[16]; |
|
|
free(wp->shell); |
free(wp->shell); |
wp->shell = xstrdup(shell); |
wp->shell = xstrdup(shell); |
} |
} |
if (cwd != NULL) { |
if (cwd != -1) { |
free(wp->cwd); |
close(wp->cwd); |
wp->cwd = xstrdup(cwd); |
wp->cwd = dup(cwd); |
} |
} |
|
|
log_debug("spawn: %s -- %s", wp->shell, wp->cmd); |
log_debug("spawn: %s -- %s", wp->shell, wp->cmd); |
|
|
xasprintf(cause, "%s: %s", cmd, strerror(errno)); |
xasprintf(cause, "%s: %s", cmd, strerror(errno)); |
return (-1); |
return (-1); |
case 0: |
case 0: |
if (chdir(wp->cwd) != 0) |
if (fchdir(wp->cwd) != 0) |
chdir("/"); |
chdir("/"); |
|
|
if (tcgetattr(STDIN_FILENO, &tio2) != 0) |
if (tcgetattr(STDIN_FILENO, &tio2) != 0) |