aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES6
-rw-r--r--Makefile4
-rw-r--r--cmd-kill-session.c64
-rw-r--r--cmd.c3
-rw-r--r--tmux.114
-rw-r--r--tmux.h3
6 files changed, 84 insertions, 10 deletions
diff --git a/CHANGES b/CHANGES
index 021cbe39..268fe65e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+12 November 2007
+
+* (nicm) kill-session command.
+
09 November 2007
* (nicm) C-space is now "^ " not "^@".
@@ -198,4 +202,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.64 2007-11-09 17:09:34 nicm Exp $
+$Id: CHANGES,v 1.65 2007-11-12 14:21:40 nicm Exp $
diff --git a/Makefile b/Makefile
index 431eeedd..43884440 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.38 2007-11-09 15:23:28 nicm Exp $
+# $Id: Makefile,v 1.39 2007-11-12 14:21:40 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean
@@ -25,7 +25,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \
cmd-refresh-session.c cmd-kill-window.c cmd-list-clients.c \
cmd-has-session.c cmd-link-window.c cmd-unlink-window.c \
- cmd-swap-window.c cmd-rename-session.c
+ cmd-swap-window.c cmd-rename-session.c cmd-kill-session.c
CC?= cc
INCDIRS+= -I. -I- -I/usr/local/include
diff --git a/cmd-kill-session.c b/cmd-kill-session.c
new file mode 100644
index 00000000..45479624
--- /dev/null
+++ b/cmd-kill-session.c
@@ -0,0 +1,64 @@
+/* $Id: cmd-kill-session.c,v 1.1 2007-11-12 14:21:40 nicm Exp $ */
+
+/*
+ * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include <getopt.h>
+#include <stdlib.h>
+
+#include "tmux.h"
+
+/*
+ * Destroy session, detaching all clients attached to it and destroying any
+ * windows linked only to this session.
+ *
+ * Note this deliberately has no alias to make it hard to hit by accident.
+ */
+
+void cmd_kill_session_exec(void *, struct cmd_ctx *);
+
+const struct cmd_entry cmd_kill_session_entry = {
+ "kill-session", NULL, "",
+ 0,
+ NULL,
+ cmd_kill_session_exec,
+ NULL,
+ NULL,
+ NULL,
+};
+
+void
+cmd_kill_session_exec(unused void *ptr, struct cmd_ctx *ctx)
+{
+ struct client *c;
+ struct session *s = ctx->session;
+ u_int i;
+
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ c = ARRAY_ITEM(&clients, i);
+ if (c->session == s) {
+ c->session = NULL;
+ server_write_client(c, MSG_EXIT, NULL, 0);
+ }
+ }
+
+ session_destroy(s);
+
+ if (!(ctx->flags & CMD_KEY))
+ server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+}
diff --git a/cmd.c b/cmd.c
index d0f6ab61..1396d04c 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.25 2007-11-09 11:02:01 nicm Exp $ */
+/* $Id: cmd.c,v 1.26 2007-11-12 14:21:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -28,6 +28,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_bind_key_entry,
&cmd_detach_session_entry,
&cmd_has_session_entry,
+ &cmd_kill_session_entry,
&cmd_kill_window_entry,
&cmd_last_window_entry,
&cmd_link_window_entry,
diff --git a/tmux.1 b/tmux.1
index 60931617..8f952d90 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1,4 +1,4 @@
-.\" $Id: tmux.1,v 1.6 2007-11-09 17:05:42 nicm Exp $
+.\" $Id: tmux.1,v 1.7 2007-11-12 14:21:40 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -40,10 +40,12 @@ necessary and holds a number of
.Em sessions ,
each of which may have a number of
.Em windows
-connected to it. Any number of clients may connect to a session, or the server
-may be controlled by issuing commands using the
-.Nm
-binary. Communication takes place through a socket, by default placed in
+connected to it. Any number of
+.Em clients
+may connect to a session, or the server
+may be controlled by issuing commands with
+.Nm .
+Communication takes place through a socket, by default placed in
.Pa /tmp .
.Pp
The options are as follows:
@@ -135,6 +137,8 @@ supports the following commands:
.It Xo Ic has-session
.Xc
.D1 (alias: Ic has )
+.It Xo Ic kill-session
+.Xc
.It Xo Ic kill-window
.Op Fl i Ar index
.Xc
diff --git a/tmux.h b/tmux.h
index 47cc66a3..1620c6fc 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.77 2007-11-09 11:02:01 nicm Exp $ */
+/* $Id: tmux.h,v 1.78 2007-11-12 14:21:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -571,6 +571,7 @@ extern const struct cmd_entry cmd_attach_session_entry;
extern const struct cmd_entry cmd_bind_key_entry;
extern const struct cmd_entry cmd_detach_session_entry;
extern const struct cmd_entry cmd_has_session_entry;
+extern const struct cmd_entry cmd_kill_session_entry;
extern const struct cmd_entry cmd_kill_window_entry;
extern const struct cmd_entry cmd_last_window_entry;
extern const struct cmd_entry cmd_link_window_entry;