diff --git a/tmux.c b/tmux.c index b3ef4fa3..00b68246 100644 --- a/tmux.c +++ b/tmux.c @@ -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 @@ -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)");