Home | History | Annotate | Line # | Download | only in dist
cmd-kill-server.c revision 1.1.1.5.2.1
      1      1.1.1.5  christos /* $OpenBSD$ */
      2          1.1      jmmv 
      3          1.1      jmmv /*
      4          1.1      jmmv  * Copyright (c) 2007 Nicholas Marriott <nicm (at) users.sourceforge.net>
      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.5.2.1  pgoyette 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      jmmv 	"kill-server", NULL,
     34      1.1.1.2      jmmv 	"", 0, 0,
     35          1.1      jmmv 	"",
     36      1.1.1.2      jmmv 	0,
     37      1.1.1.3  christos 	cmd_kill_server_exec
     38      1.1.1.3  christos };
     39      1.1.1.3  christos 
     40      1.1.1.3  christos const struct cmd_entry cmd_start_server_entry = {
     41      1.1.1.3  christos 	"start-server", "start",
     42      1.1.1.3  christos 	"", 0, 0,
     43      1.1.1.3  christos 	"",
     44      1.1.1.3  christos 	CMD_STARTSERVER,
     45      1.1.1.2      jmmv 	cmd_kill_server_exec
     46          1.1      jmmv };
     47          1.1      jmmv 
     48  1.1.1.5.2.1  pgoyette static enum cmd_retval
     49  1.1.1.5.2.1  pgoyette cmd_kill_server_exec(struct cmd *self, __unused struct cmdq_item *item)
     50          1.1      jmmv {
     51      1.1.1.3  christos 	if (self->entry == &cmd_kill_server_entry)
     52      1.1.1.3  christos 		kill(getpid(), SIGTERM);
     53          1.1      jmmv 
     54      1.1.1.3  christos 	return (CMD_RETURN_NORMAL);
     55          1.1      jmmv }
     56