diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-08-28 09:36:33 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-08-28 09:36:33 +0000 |
commit | 3846c9b9a8137c2071e6d7c44cf7385f6d7df179 (patch) | |
tree | b9fb3afc2c17be2c5fec939fc269803794a1b6fe /tmux.c | |
parent | 48ab20871bb99a929eb4ea64671d77ad58646e29 (diff) | |
download | rtmux-3846c9b9a8137c2071e6d7c44cf7385f6d7df179.tar.gz rtmux-3846c9b9a8137c2071e6d7c44cf7385f6d7df179.tar.bz2 rtmux-3846c9b9a8137c2071e6d7c44cf7385f6d7df179.zip |
Set up signal handlers before fork so server has them too.
Diffstat (limited to 'tmux.c')
-rw-r--r-- | tmux.c | 54 |
1 files changed, 27 insertions, 27 deletions
@@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.5 2007-08-28 08:30:36 nicm Exp $ */ +/* $Id: tmux.c,v 1.6 2007-08-28 09:36:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -154,6 +154,32 @@ main(int argc, char **argv) err(1, "realpath"); xfree(path); + /* Set up signal handlers. */ + sigemptyset(&act.sa_mask); + act.sa_flags = SA_RESTART; + + act.sa_handler = SIG_IGN; + if (sigaction(SIGPIPE, &act, NULL) != 0) + err(1, "sigaction"); + if (sigaction(SIGUSR1, &act, NULL) != 0) + err(1, "sigaction"); + if (sigaction(SIGUSR2, &act, NULL) != 0) + err(1, "sigaction"); + if (sigaction(SIGINT, &act, NULL) != 0) + err(1, "sigaction"); + if (sigaction(SIGTSTP, &act, NULL) != 0) + err(1, "sigaction"); + if (sigaction(SIGQUIT, &act, NULL) != 0) + err(1, "sigaction"); + + act.sa_handler = sighandler; + if (sigaction(SIGWINCH, &act, NULL) != 0) + err(1, "sigaction"); + if (sigaction(SIGTERM, &act, NULL) != 0) + err(1, "sigaction"); + if (sigaction(SIGCHLD, &act, NULL) != 0) + err(1, "sigaction"); + /* Start server if necessary. */ n = 0; restart: @@ -195,32 +221,6 @@ restart: if (!isatty(STDOUT_FILENO)) errx(1, "stdout is not a tty"); - /* Set up signal handlers. */ - sigemptyset(&act.sa_mask); - act.sa_flags = SA_RESTART; - - act.sa_handler = SIG_IGN; - if (sigaction(SIGPIPE, &act, NULL) != 0) - err(1, "sigaction"); - if (sigaction(SIGUSR1, &act, NULL) != 0) - err(1, "sigaction"); - if (sigaction(SIGUSR2, &act, NULL) != 0) - err(1, "sigaction"); - if (sigaction(SIGINT, &act, NULL) != 0) - err(1, "sigaction"); - if (sigaction(SIGTSTP, &act, NULL) != 0) - err(1, "sigaction"); - if (sigaction(SIGQUIT, &act, NULL) != 0) - err(1, "sigaction"); - - act.sa_handler = sighandler; - if (sigaction(SIGWINCH, &act, NULL) != 0) - err(1, "sigaction"); - if (sigaction(SIGTERM, &act, NULL) != 0) - err(1, "sigaction"); - if (sigaction(SIGCHLD, &act, NULL) != 0) - err(1, "sigaction"); - /* Find window size. */ if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1) err(1, "ioctl(TIOCGWINSZ)"); |