mirror of
				https://codeberg.org/dwl/dwl.git
				synced 2025-10-31 20:14:20 +00:00 
			
		
		
		
	increase RLIMIT_CORE (generate a coredump)
This commit is contained in:
		
							parent
							
								
									d05edf6760
								
							
						
					
					
						commit
						9433f353b3
					
				
							
								
								
									
										10
									
								
								dwl.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								dwl.c
									
									
									
									
									
								
							| @ -10,6 +10,7 @@ | |||||||
| #include <signal.h> | #include <signal.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|  | #include <sys/resource.h> | ||||||
| #include <sys/wait.h> | #include <sys/wait.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| @ -328,6 +329,8 @@ static void zoom(const Arg *arg); | |||||||
| 
 | 
 | ||||||
| /* variables */ | /* variables */ | ||||||
| static const char broken[] = "broken"; | static const char broken[] = "broken"; | ||||||
|  | static struct rlimit oldrlimit; | ||||||
|  | static struct rlimit newrlimit; | ||||||
| static const char *cursor_image = "left_ptr"; | static const char *cursor_image = "left_ptr"; | ||||||
| static pid_t child_pid = -1; | static pid_t child_pid = -1; | ||||||
| static void *exclusive_focus; | static void *exclusive_focus; | ||||||
| @ -463,6 +466,7 @@ autostartexec(void) { | |||||||
| 	autostart_pids = calloc(autostart_len, sizeof(pid_t)); | 	autostart_pids = calloc(autostart_len, sizeof(pid_t)); | ||||||
| 	for (p = autostart; *p; i++, p++) { | 	for (p = autostart; *p; i++, p++) { | ||||||
| 		if ((autostart_pids[i] = fork()) == 0) { | 		if ((autostart_pids[i] = fork()) == 0) { | ||||||
|  | 			setrlimit(RLIMIT_CORE, &oldrlimit); | ||||||
| 			setsid(); | 			setsid(); | ||||||
| 			execvp(*p, (char *const *)p); | 			execvp(*p, (char *const *)p); | ||||||
| 			fprintf(stderr, "dwl: execvp %s\n", *p); | 			fprintf(stderr, "dwl: execvp %s\n", *p); | ||||||
| @ -2207,6 +2211,7 @@ run(char *startup_cmd) | |||||||
| 		if ((child_pid = fork()) < 0) | 		if ((child_pid = fork()) < 0) | ||||||
| 			die("startup: fork:"); | 			die("startup: fork:"); | ||||||
| 		if (child_pid == 0) { | 		if (child_pid == 0) { | ||||||
|  | 			setrlimit(RLIMIT_CORE, &oldrlimit); | ||||||
| 			dup2(piperw[0], STDIN_FILENO); | 			dup2(piperw[0], STDIN_FILENO); | ||||||
| 			close(piperw[0]); | 			close(piperw[0]); | ||||||
| 			close(piperw[1]); | 			close(piperw[1]); | ||||||
| @ -2613,6 +2618,7 @@ void | |||||||
| spawn(const Arg *arg) | spawn(const Arg *arg) | ||||||
| { | { | ||||||
| 	if (fork() == 0) { | 	if (fork() == 0) { | ||||||
|  | 		setrlimit(RLIMIT_CORE, &oldrlimit); | ||||||
| 		dup2(STDERR_FILENO, STDOUT_FILENO); | 		dup2(STDERR_FILENO, STDOUT_FILENO); | ||||||
| 		setsid(); | 		setsid(); | ||||||
| 		execvp(((char **)arg->v)[0], (char **)arg->v); | 		execvp(((char **)arg->v)[0], (char **)arg->v); | ||||||
| @ -3066,6 +3072,10 @@ main(int argc, char *argv[]) | |||||||
| 	char *startup_cmd = NULL; | 	char *startup_cmd = NULL; | ||||||
| 	int c; | 	int c; | ||||||
| 
 | 
 | ||||||
|  | 	getrlimit(RLIMIT_CORE, &oldrlimit); | ||||||
|  | 	newrlimit.rlim_cur = newrlimit.rlim_max = oldrlimit.rlim_max; | ||||||
|  | 	setrlimit(RLIMIT_CORE, &newrlimit); | ||||||
|  | 
 | ||||||
| 	while ((c = getopt(argc, argv, "s:hv")) != -1) { | 	while ((c = getopt(argc, argv, "s:hv")) != -1) { | ||||||
| 		if (c == 's') | 		if (c == 's') | ||||||
| 			startup_cmd = optarg; | 			startup_cmd = optarg; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Leonardo Hernández Hernández
						Leonardo Hernández Hernández