Home | History | Annotate | Line # | Download | only in dist
cmd-kill-server.c revision 1.1.1.7
      1  1.1.1.5  christos /* $OpenBSD$ */
      2      1.1      jmmv 
      3      1.1      jmmv /*
      4  1.1.1.6  christos  * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott (at) gmail.com>
      5      1.1      jmmv  *
      6      1.1      jmmv  * Permission to use, copy, modify, and distribute this software for any
      7      1.1      jmmv  * purpose with or without fee is hereby granted, provided that the above
      8      1.1      jmmv  * copyright notice and this permission notice appear in all copies.
      9      1.1      jmmv  *
     10      1.1      jmmv  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     11      1.1      jmmv  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     12      1.1      jmmv  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     13      1.1      jmmv  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     14      1.1      jmmv  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
     15      1.1      jmmv  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
     16      1.1      jmmv  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     17      1.1      jmmv  */
     18      1.1      jmmv 
     19      1.1      jmmv #include <sys/types.h>
     20      1.1      jmmv 
     21      1.1      jmmv #include <signal.h>
     22      1.1      jmmv #include <unistd.h>
     23      1.1      jmmv 
     24      1.1      jmmv #include "tmux.h"
     25      1.1      jmmv 
     26      1.1      jmmv /*
     27      1.1      jmmv  * Kill the server and do nothing else.
     28      1.1      jmmv  */
     29      1.1      jmmv 
     30  1.1.1.7  christos static enum cmd_retval	cmd_kill_server_exec(struct cmd *, struct cmdq_item *);
     31      1.1      jmmv 
     32      1.1      jmmv const struct cmd_entry cmd_kill_server_entry = {
     33  1.1.1.6  christos 	.name = "kill-server",
     34  1.1.1.6  christos 	.alias = NULL,
     35  1.1.1.6  christos 
     36  1.1.1.6  christos 	.args = { "", 0, 0 },
     37  1.1.1.6  christos 	.usage = "",
     38  1.1.1.6  christos 
     39  1.1.1.6  christos 	.flags = 0,
     40  1.1.1.6  christos 	.exec = cmd_kill_server_exec
     41  1.1.1.3  christos };
     42  1.1.1.3  christos 
     43  1.1.1.3  christos const struct cmd_entry cmd_start_server_entry = {
     44  1.1.1.6  christos 	.name = "start-server",
     45  1.1.1.6  christos 	.alias = "start",
     46  1.1.1.6  christos 
     47  1.1.1.6  christos 	.args = { "", 0, 0 },
     48  1.1.1.6  christos 	.usage = "",
     49  1.1.1.6  christos 
     50  1.1.1.6  christos 	.flags = CMD_STARTSERVER,
     51  1.1.1.6  christos 	.exec = cmd_kill_server_exec
     52      1.1      jmmv };
     53      1.1      jmmv 
     54  1.1.1.7  christos static enum cmd_retval
     55  1.1.1.7  christos cmd_kill_server_exec(struct cmd *self, __unused struct cmdq_item *item)
     56      1.1      jmmv {
     57  1.1.1.3  christos 	if (self->entry == &cmd_kill_server_entry)
     58  1.1.1.3  christos 		kill(getpid(), SIGTERM);
     59      1.1      jmmv 
     60  1.1.1.3  christos 	return (CMD_RETURN_NORMAL);
     61      1.1      jmmv }
     62