diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-09-27 09:15:58 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-09-27 09:15:58 +0000 |
commit | 3fa8f1636486420b9f27b129dbd0f36015d4c24b (patch) | |
tree | c018e47c9eb2d78f518a941e7cd87ebe2eb63ab9 /window.c | |
parent | 187648e8d1d6bc80113e829d7895e1c81ddd3c17 (diff) |
Adjust $TMUX environ var to include session index, and don't compact session list on release. Also fix some argument types.
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 41 |
1 files changed, 9 insertions, 32 deletions
@@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.10 2007-09-21 20:45:06 nicm Exp $ */ +/* $Id: window.c,v 1.11 2007-09-27 09:15:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -52,14 +52,14 @@ struct windows windows; /* Create a new window. */ struct window * -window_create(const char *cmd, u_int sx, u_int sy) +window_create(const char *cmd, const char **environ, u_int sx, u_int sy) { struct window *w; struct winsize ws; struct termios tio; - struct sigaction act; int fd, mode; - char pid[16], *ptr, *name; + char *ptr, *name; + const char **entry; memset(&ws, 0, sizeof ws); ws.ws_col = sx; @@ -73,40 +73,17 @@ window_create(const char *cmd, u_int sx, u_int sy) memcpy(&tio.c_cc, ttydefchars, sizeof tio.c_cc); cfsetspeed(&tio, TTYDEF_SPEED); - xsnprintf(pid, sizeof pid, "%ld", (long) getpid()); switch (forkpty(&fd, NULL, &tio, &ws)) { case -1: return (NULL); case 0: - if (setenv("TMUX", pid, 1) != 0) - fatal("setenv failed"); - if (setenv("TERM", "screen", 1) != 0) - fatal("setenv failed"); + for (entry = environ; *entry != NULL; entry++) { + if (putenv(*entry) != 0) + fatal("putenv failed"); + } + sigreset(); log_close(); - memset(&act, 0, sizeof act); - sigemptyset(&act.sa_mask); - - act.sa_handler = SIG_DFL; - if (sigaction(SIGPIPE, &act, NULL) != 0) - fatal("sigaction failed"); - if (sigaction(SIGUSR1, &act, NULL) != 0) - fatal("sigaction failed"); - if (sigaction(SIGUSR2, &act, NULL) != 0) - fatal("sigaction failed"); - if (sigaction(SIGINT, &act, NULL) != 0) - fatal("sigaction failed"); - if (sigaction(SIGTSTP, &act, NULL) != 0) - fatal("sigaction failed"); - if (sigaction(SIGQUIT, &act, NULL) != 0) - fatal("sigaction failed"); - if (sigaction(SIGWINCH, &act, NULL) != 0) - fatal("sigaction failed"); - if (sigaction(SIGTERM, &act, NULL) != 0) - fatal("sigaction failed"); - if (sigaction(SIGCHLD, &act, NULL) != 0) - fatal("sigaction failed"); - execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL); fatal("execl failed"); } |