From ffcc6e24f5dfa98dfcdcae39f5f85c1f5b8d52e1 Mon Sep 17 00:00:00 2001 From: Måns Rullgård Date: Wed, 20 Jan 2010 06:42:39 +0000 Subject: Add -timelimit option This option limits the CPU time used by ffmpeg to the number of seconds specified. After this time, the OS sends a SIGXCPU signal, which we handle and attempt to exit cleanly. If the process is stuck, the OS will deliver a SIGKILL one second later, forcibly terminating the process. This functionality is useful in automated setups where a runaway ffmpeg process would otherwise go undetected. Originally committed as revision 21347 to svn://svn.ffmpeg.org/ffmpeg/trunk --- ffmpeg.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ffmpeg.c') diff --git a/ffmpeg.c b/ffmpeg.c index 02786070e4..4b956ba71d 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -353,6 +353,10 @@ static void term_init(void) signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */ signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */ +#ifdef SIGXCPU + signal(SIGXCPU, sigterm_handler); +#endif + /* register a function to be called at normal program termination */ @@ -3863,6 +3867,7 @@ static const OptionDef options[] = { { "dframes", OPT_INT | HAS_ARG, {(void*)&max_frames[CODEC_TYPE_DATA]}, "set the number of data frames to record", "number" }, { "benchmark", OPT_BOOL | OPT_EXPERT, {(void*)&do_benchmark}, "add timings for benchmarking" }, + { "timelimit", OPT_FUNC2 | HAS_ARG, {(void*)opt_timelimit}, "set max runtime in seconds", "limit" }, { "dump", OPT_BOOL | OPT_EXPERT, {(void*)&do_pkt_dump}, "dump each input packet" }, { "hex", OPT_BOOL | OPT_EXPERT, {(void*)&do_hex_dump}, -- cgit v1.2.3