Skip to content

Commit

Permalink
still testing, as on i watched reusing fd 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ftasnetamot committed Aug 26, 2024
1 parent d4c4b0c commit 8908dc4
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions sslh-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8908dc4

Please sign in to comment.