Commit a4cd2ad8 authored by Janne Grunau's avatar Janne Grunau

avserver: use freopen to redirect stdin/out/err to /dev/null

parent ada51a33
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#endif #endif
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include "libavformat/avformat.h" #include "libavformat/avformat.h"
// FIXME those are internal headers, avserver _really_ shouldn't use them // FIXME those are internal headers, avserver _really_ shouldn't use them
#include "libavformat/ffm.h" #include "libavformat/ffm.h"
...@@ -513,13 +514,12 @@ static void start_children(FFStream *feed) ...@@ -513,13 +514,12 @@ static void start_children(FFStream *feed)
close(i); close(i);
if (!avserver_debug) { if (!avserver_debug) {
i = open("/dev/null", O_RDWR); if (!freopen("/dev/null", "r", stdin))
if (i != -1) { http_log("failed to redirect STDIN to /dev/null\n;");
dup2(i, 0); if (!freopen("/dev/null", "w", stdout))
dup2(i, 1); http_log("failed to redirect STDOUT to /dev/null\n;");
dup2(i, 2); if (!freopen("/dev/null", "w", stderr))
close(i); http_log("failed to redirect STDERR to /dev/null\n;");
}
} }
signal(SIGPIPE, SIG_DFL); signal(SIGPIPE, SIG_DFL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment