mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 09:15:29 +01:00 
			
		
		
		
	Redirect stdin/stderr/stdout to /dev/null in daemon mode
This commit is contained in:
		@@ -635,6 +635,7 @@ void daemonize()
 | 
			
		||||
		pidfile = 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	pid_t pid = fork();
 | 
			
		||||
 | 
			
		||||
	if (pid > 0) {
 | 
			
		||||
@@ -648,8 +649,9 @@ void daemonize()
 | 
			
		||||
		}
 | 
			
		||||
		exit (0);
 | 
			
		||||
	} else if (pid == 0) {
 | 
			
		||||
		fclose(stdout);
 | 
			
		||||
		fclose(stderr);
 | 
			
		||||
		freopen("/dev/null","w",stdout);
 | 
			
		||||
		freopen("/dev/null","w",stderr);
 | 
			
		||||
		freopen("/dev/null","r",stdout);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user