Skip to content

Commit 8643144

Browse files
committed
Merge branch 'patch-1' of https://github.com/antroseco/fio
* 'patch-1' of https://github.com/antroseco/fio: server: reopen standard streams to /dev/null
2 parents df9e8b6 + d609609 commit 8643144

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

server.c

+18-3
Original file line numberDiff line numberDiff line change
@@ -2565,6 +2565,7 @@ static int write_pid(pid_t pid, const char *pidfile)
25652565
*/
25662566
int fio_start_server(char *pidfile)
25672567
{
2568+
FILE *file;
25682569
pid_t pid;
25692570
int ret;
25702571

@@ -2597,14 +2598,28 @@ int fio_start_server(char *pidfile)
25972598
setsid();
25982599
openlog("fio", LOG_NDELAY|LOG_NOWAIT|LOG_PID, LOG_USER);
25992600
log_syslog = true;
2600-
close(STDIN_FILENO);
2601-
close(STDOUT_FILENO);
2602-
close(STDERR_FILENO);
2601+
2602+
file = freopen("/dev/null", "r", stdin);
2603+
if (!file)
2604+
perror("freopen");
2605+
2606+
file = freopen("/dev/null", "w", stdout);
2607+
if (!file)
2608+
perror("freopen");
2609+
2610+
file = freopen("/dev/null", "w", stderr);
2611+
if (!file)
2612+
perror("freopen");
2613+
26032614
f_out = NULL;
26042615
f_err = NULL;
26052616

26062617
ret = fio_server();
26072618

2619+
fclose(stdin);
2620+
fclose(stdout);
2621+
fclose(stderr);
2622+
26082623
closelog();
26092624
unlink(pidfile);
26102625
free(pidfile);

0 commit comments

Comments
 (0)