mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-12 15:17:14 +03:00
still testing, as on i watched reusing fd 0
This commit is contained in:
parent
109052fdc7
commit
4def95865c
@ -288,14 +288,12 @@ int main(int argc, char *argv[], char* envp[])
|
||||
if (!cfg.foreground) {
|
||||
if (fork() > 0) exit(0); /* Detach */
|
||||
// close stdin, stderr, stdout
|
||||
// closing stdin frees a filehandle, and 0 will not be reused, so no problem
|
||||
// with control-jobs, trying to catch fd/0
|
||||
close(fileno(stdin));
|
||||
int newfd;
|
||||
// duplicating a handle connected to /dev/null to stdout and stderr
|
||||
// so we don't run in any problems, when a control-job wor whats-o-ever will
|
||||
// grab stdout and stderr
|
||||
if ((newfd = open("/dev/null", O_RDWR))) {
|
||||
dup2 (newfd, STDIN_FILENO);
|
||||
dup2 (newfd, STDOUT_FILENO);
|
||||
dup2 (newfd, STDERR_FILENO);
|
||||
// close the helper handle, as this is now unnecessary
|
||||
|
Loading…
x
Reference in New Issue
Block a user