=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/session.c,v retrieving revision 1.83 retrieving revision 1.84 diff -u -r1.83 -r1.84 --- src/usr.bin/tmux/session.c 2019/03/16 17:14:07 1.83 +++ src/usr.bin/tmux/session.c 2019/04/17 14:37:48 1.84 @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.83 2019/03/16 17:14:07 nicm Exp $ */ +/* $OpenBSD: session.c,v 1.84 2019/04/17 14:37:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -112,12 +112,10 @@ /* Create a new session. */ struct session * -session_create(const char *prefix, const char *name, int argc, char **argv, - const char *path, const char *cwd, struct environ *env, struct options *oo, - struct termios *tio, int idx, char **cause) +session_create(const char *prefix, const char *name, const char *cwd, + struct environ *env, struct options *oo, struct termios *tio) { struct session *s; - struct winlink *wl; s = xcalloc(1, sizeof *s); s->references = 1; @@ -129,10 +127,7 @@ TAILQ_INIT(&s->lastw); RB_INIT(&s->windows); - s->environ = environ_create(); - if (env != NULL) - environ_copy(env, s->environ); - + s->environ = env; s->options = oo; s->hooks = hooks_create(global_hooks); @@ -166,17 +161,6 @@ fatal("gettimeofday failed"); session_update_activity(s, &s->creation_time); - if (argc >= 0) { - wl = session_new(s, NULL, argc, argv, path, cwd, idx, cause); - if (wl == NULL) { - session_destroy(s, __func__); - return (NULL); - } - session_select(s, RB_ROOT(&s->windows)->idx); - } - - log_debug("session %s created", s->name); - return (s); } @@ -220,7 +204,7 @@ /* Destroy a session. */ void -session_destroy(struct session *s, const char *from) +session_destroy(struct session *s, int notify, const char *from) { struct winlink *wl; @@ -228,7 +212,8 @@ s->curw = NULL; RB_REMOVE(sessions, &sessions, s); - notify_session("session-closed", s); + if (notify) + notify_session("session-closed", s); free(s->tio); @@ -338,45 +323,6 @@ return (s2); } -/* Create a new window on a session. */ -struct winlink * -session_new(struct session *s, const char *name, int argc, char **argv, - const char *path, const char *cwd, int idx, char **cause) -{ - struct window *w; - struct winlink *wl; - struct environ *env; - const char *shell; - u_int hlimit, sx, sy; - - if ((wl = winlink_add(&s->windows, idx)) == NULL) { - xasprintf(cause, "index in use: %d", idx); - return (NULL); - } - wl->session = s; - - shell = options_get_string(s->options, "default-shell"); - if (*shell == '\0' || areshell(shell)) - shell = _PATH_BSHELL; - - default_window_size(s, NULL, &sx, &sy, -1); - hlimit = options_get_number(s->options, "history-limit"); - env = environ_for_session(s, 0); - w = window_create_spawn(name, argc, argv, path, shell, cwd, env, s->tio, - sx, sy, hlimit, cause); - if (w == NULL) { - winlink_remove(&s->windows, wl); - environ_free(env); - return (NULL); - } - winlink_set_window(wl, w); - environ_free(env); - notify_session_window("window-linked", s, w); - - session_group_synchronize_from(s); - return (wl); -} - /* Attach a window to a session. */ struct winlink * session_attach(struct session *s, struct window *w, int idx, char **cause) @@ -412,7 +358,7 @@ session_group_synchronize_from(s); if (RB_EMPTY(&s->windows)) { - session_destroy(s, __func__); + session_destroy(s, 1, __func__); return (1); } return (0);