mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	spawn: avoid zombie children without handling SIGCHLD
Current handling of SIGCHLD prevents some terminals, for example sakura and alacritty, to freeze on ctrl+D. Related to PR #10
This commit is contained in:
		
							parent
							
								
									f4cbd4ff61
								
							
						
					
					
						commit
						1a38898f34
					
				
					 2 changed files with 43 additions and 25 deletions
				
			
		
							
								
								
									
										19
									
								
								src/server.c
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								src/server.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -14,7 +14,6 @@
 | 
			
		|||
 | 
			
		||||
static struct wlr_compositor *compositor;
 | 
			
		||||
static struct wl_event_source *sighup_source;
 | 
			
		||||
static struct wl_event_source *sigchld_source;
 | 
			
		||||
static struct wl_event_source *sigint_source;
 | 
			
		||||
static struct wl_event_source *sigterm_source;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -34,19 +33,6 @@ handle_sighup(int signal, void *data)
 | 
			
		|||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
handle_sigchld(int signal, void *data)
 | 
			
		||||
{
 | 
			
		||||
	int status;
 | 
			
		||||
	pid_t pid;
 | 
			
		||||
 | 
			
		||||
	while ((pid = waitpid(-1, &status, WNOHANG)) > 0);
 | 
			
		||||
	if (pid < 0) {
 | 
			
		||||
		wlr_log_errno(WLR_ERROR, "waitpid");
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
handle_sigterm(int signal, void *data)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -86,8 +72,6 @@ server_init(struct server *server)
 | 
			
		|||
	event_loop = wl_display_get_event_loop(server->wl_display);
 | 
			
		||||
	sighup_source = wl_event_loop_add_signal(
 | 
			
		||||
		event_loop, SIGHUP, handle_sighup, &server->wl_display);
 | 
			
		||||
	sigchld_source = wl_event_loop_add_signal(
 | 
			
		||||
		event_loop, SIGCHLD, handle_sigchld, NULL);
 | 
			
		||||
	sigint_source = wl_event_loop_add_signal(
 | 
			
		||||
		event_loop, SIGINT, handle_sigterm, NULL);
 | 
			
		||||
	sigterm_source = wl_event_loop_add_signal(
 | 
			
		||||
| 
						 | 
				
			
			@ -263,9 +247,6 @@ server_finish(struct server *server)
 | 
			
		|||
	if (sighup_source) {
 | 
			
		||||
		wl_event_source_remove(sighup_source);
 | 
			
		||||
	}
 | 
			
		||||
	if (sigchld_source) {
 | 
			
		||||
		wl_event_source_remove(sigchld_source);
 | 
			
		||||
	}
 | 
			
		||||
	wl_display_destroy_clients(server->wl_display);
 | 
			
		||||
 | 
			
		||||
	seat_finish(server);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue