Revision ffcc6e24

View differences:

cmdutils.c
41 41
#if CONFIG_NETWORK
42 42
#include "libavformat/network.h"
43 43
#endif
44
#if HAVE_SYS_RESOURCE_H
45
#include <sys/resource.h>
46
#endif
44 47

  
45 48
#undef exit
46 49

  
......
257 260
    return 0;
258 261
}
259 262

  
263
int opt_timelimit(const char *opt, const char *arg)
264
{
265
#if HAVE_SYS_RESOURCE_H
266
    int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
267
    struct rlimit rl = { lim, lim + 1 };
268
    if (setrlimit(RLIMIT_CPU, &rl))
269
        perror("setrlimit");
270
#else
271
    fprintf(stderr, "Warning: -%s not implemented on this OS\n", opt);
272
#endif
273
    return 0;
274
}
275

  
260 276
void set_context_opts(void *ctx, void *opts_ctx, int flags)
261 277
{
262 278
    int i;
cmdutils.h
56 56
int opt_loglevel(const char *opt, const char *arg);
57 57

  
58 58
/**
59
 * Limit the execution time.
60
 */
61
int opt_timelimit(const char *opt, const char *arg);
62

  
63
/**
59 64
 * Parses a string and returns its corresponding value as a double.
60 65
 * Exits from the application if the string cannot be correctly
61 66
 * parsed or the corresponding value is invalid.
ffmpeg.c
353 353

  
354 354
    signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).  */
355 355
    signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
356
#ifdef SIGXCPU
357
    signal(SIGXCPU, sigterm_handler);
358
#endif
359

  
356 360
    /*
357 361
    register a function to be called at normal program termination
358 362
    */
......
3863 3867
    { "dframes", OPT_INT | HAS_ARG, {(void*)&max_frames[CODEC_TYPE_DATA]}, "set the number of data frames to record", "number" },
3864 3868
    { "benchmark", OPT_BOOL | OPT_EXPERT, {(void*)&do_benchmark},
3865 3869
      "add timings for benchmarking" },
3870
    { "timelimit", OPT_FUNC2 | HAS_ARG, {(void*)opt_timelimit}, "set max runtime in seconds", "limit" },
3866 3871
    { "dump", OPT_BOOL | OPT_EXPERT, {(void*)&do_pkt_dump},
3867 3872
      "dump each input packet" },
3868 3873
    { "hex", OPT_BOOL | OPT_EXPERT, {(void*)&do_hex_dump},

Also available in: Unified diff