mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Set up signal handlers before fork so server has them too.
This commit is contained in:
		
							
								
								
									
										54
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								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 <nicm@users.sourceforge.net> |  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||||
| @@ -154,6 +154,32 @@ main(int argc, char **argv) | |||||||
| 		err(1, "realpath"); | 		err(1, "realpath"); | ||||||
| 	xfree(path); | 	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. */ | 	/* Start server if necessary. */ | ||||||
| 	n = 0; | 	n = 0; | ||||||
| restart: | restart: | ||||||
| @@ -195,32 +221,6 @@ restart: | |||||||
| 	if (!isatty(STDOUT_FILENO)) | 	if (!isatty(STDOUT_FILENO)) | ||||||
| 		errx(1, "stdout is not a tty"); | 		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. */ | 	/* Find window size. */ | ||||||
| 	if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1) | 	if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1) | ||||||
| 		err(1, "ioctl(TIOCGWINSZ)"); | 		err(1, "ioctl(TIOCGWINSZ)"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nicholas Marriott
					Nicholas Marriott