[FFmpeg-devel] [PATCH] ffserver: respect HAVE_FORK to work on Linux/no-mmu systems

Mike Frysinger vapier
Thu Oct 22 12:23:53 CEST 2009


Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 ffserver.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index da45cfa..80297ee 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -406,7 +406,11 @@ static void start_children(FFStream *feed)
         if (feed->child_argv && !feed->pid) {
             feed->pid_start = time(0);
 
+#if HAVE_FORK
             feed->pid = fork();
+#else
+            feed->pid = vfork();
+#endif
 
             if (feed->pid < 0) {
                 http_log("Unable to create children\n");
@@ -4530,6 +4534,7 @@ int main(int argc, char **argv)
 
     /* put the process in background and detach it from its TTY */
     if (ffserver_daemon) {
+#if HAVE_FORK
         int pid;
 
         pid = fork();
@@ -4551,6 +4556,16 @@ int main(int argc, char **argv)
             close(2);
             dup(0);
         }
+#else
+        int logfd = -1;
+        if (strcmp(logfilename, "-") == 0)
+            logfd = dup(1);
+        daemon(1, 0);
+        if (logfd != -1) {
+            dup2(logfd, 1);
+            close(logfd);
+        }
+#endif
     }
 
     /* signal init */
-- 
1.6.5.1




More information about the ffmpeg-devel mailing list