[FFmpeg-devel] "OPW Qualification Task: Enable daemon mode for FFserver"
Stefano Sabatini
stefasab at gmail.com
Mon Nov 10 16:12:59 CET 2014
On date Monday 2014-11-10 13:26:14 +0530, Binathi Bingi encoded:
[...]
> From c9d037758693a1522258a64849f7629d7cbd7408 Mon Sep 17 00:00:00 2001
> From: Binathi <binti179 at gmail.com>
Provide complete name, the patch is used to track copyright.
> Date: Tue, 4 Nov 2014 21:42:07 +0530
> Subject: [PATCH] Restore Daemon mode in FFserver
>
> Signed-off-by: Binathi Bingi <binti179 at gmail.com>
> ---
> doc/ffserver.conf | 5 +++++
> doc/ffserver.texi | 7 ++++---
> ffserver.c | 33 +++++++++++++++++++++++++++++++++
> ffserver_config.c | 4 +++-
> ffserver_config.h | 1 +
> 5 files changed, 46 insertions(+), 4 deletions(-)
>
> diff --git a/doc/ffserver.conf b/doc/ffserver.conf
> index b756961..0b63555 100644
> --- a/doc/ffserver.conf
> +++ b/doc/ffserver.conf
> @@ -25,6 +25,11 @@ MaxBandwidth 1000
> # '-' is the standard output.
> CustomLog -
>
> +# Suppress NoDaemon and enable Daemon, if you want to launch ffserver in daemon mode.
> +# If no option is specified, default option is NoDaemon.
> +#NoDaemon
> +#Daemon
Why NoDaemon followed by Daemon? This is confusing.
> +
> ##################################################################
> # Definition of the live feeds. Each live feed contains one video
> # and/or audio sequence coming from an ffmpeg encoder or another
> diff --git a/doc/ffserver.texi b/doc/ffserver.texi
> index 77273d2..5d5fc0f 100644
> --- a/doc/ffserver.texi
> +++ b/doc/ffserver.texi
> @@ -405,9 +405,10 @@ In case the commandline option @option{-d} is specified this option is
> ignored, and the log is written to standard output.
>
> @item NoDaemon
> -Set no-daemon mode. This option is currently ignored since now
> - at command{ffserver} will always work in no-daemon mode, and is
> -deprecated.
> +Set no-daemon mode. This is the default.
It would be nice to provide a more lenghty explanation about the
daemon mode. Why is it useful? How does it differ with the NoDaemon
mode? Why and how is it useful?
> +
> + at item Daemon
> +Set daemon mode. The default is NoDaemon
missing ending dot.
> @end table
>
> @section Feed section
> diff --git a/ffserver.c b/ffserver.c
> index ea2a2ae..8b005b9 100644
> --- a/ffserver.c
> +++ b/ffserver.c
> @@ -3671,6 +3671,7 @@ static void handle_child_exit(int sig)
> static void opt_debug(void)
> {
> config.debug = 1;
> + config.ffserver_daemon = 0;
> snprintf(config.logfilename, sizeof(config.logfilename), "-");
> }
>
> @@ -3737,6 +3738,38 @@ int main(int argc, char **argv)
>
> compute_bandwidth();
>
> + if (config.ffserver_daemon) {
> + pid_t ffserver_id = 0;
> + pid_t sid = 0;
> + int fd;
> + ffserver_id = fork();
> +
> + if (ffserver_id < 0) {
> + ret = AVERROR(errno);
> + av_log(NULL, AV_LOG_ERROR, "Impossible to start in daemon mode: %s\n", av_err2str(ret));
> + exit(1);
> + }
> +
> + if (ffserver_id > 0)
> + exit(0);
> +
> + sid = setsid();
> + if (sid < 0)
> + exit(1);
> +
> + fd = open("/dev/null", O_RDWR,0);
> + if (fd < 0) {
> + ret = AVERROR(errno);
> + av_log(NULL, AV_LOG_ERROR, "Unable to repoen file descriptors: %s\n", av_err2str(ret));
typo: repoen
> + exit(1);
> + }
> + dup2(fd, 0);
> + dup2(fd, 2);
> + if (strcmp(config.logfilename,"-") != 0)
nit: logfilename,_"-"
[...]
--
FFmpeg = Fanciful Fabulous Mysterious Perennial Evil Generator
More information about the ffmpeg-devel
mailing list