cmd-kill-server.c 1.6 KB

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