~ubuntu-branches/ubuntu/oneiric/bogofilter/oneiric

« back to all changes in this revision

Viewing changes to src/tests/wantcore.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams
  • Date: 2004-06-27 09:22:31 UTC
  • Revision ID: james.westby@ubuntu.com-20040627092231-u26smic0nhp7rl4z
Tags: upstream-0.92.0
Import upstream version 0.92.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* wantcore -- run a program with soft core file size limit set to hard limit
 
2
 * Copyright � 2004 Matthias Andree
 
3
 
 
4
   This program is free software; you can redistribute it and/or modify
 
5
   it under the terms of the GNU General Public License as published by
 
6
   the Free Software Foundation; either version 2 of the License, or (at
 
7
   your option) any later version.
 
8
 
 
9
   This program is distributed in the hope that it will be useful, but
 
10
   WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   General Public License for more details. The license is found in the file
 
13
   ../../COPYING.
 
14
 */
 
15
 
 
16
#include "system.h"
 
17
 
 
18
#include <sys/resource.h>
 
19
#include <unistd.h>
 
20
#include <stdlib.h>
 
21
#include <stdio.h>
 
22
 
 
23
static void barf(const char *e) __attribute__((noreturn));
 
24
static void barf(const char *e)
 
25
{
 
26
    perror(e);
 
27
    exit(EXIT_FAILURE);
 
28
}
 
29
 
 
30
int main(int argc, char **argv) {
 
31
    struct rlimit rl;
 
32
 
 
33
    if (argc <= 1) {
 
34
        fprintf(stderr, "Usage: %s program [args]\n", argv[0]);
 
35
        exit(EXIT_FAILURE);
 
36
    }
 
37
    if (getrlimit(RLIMIT_CORE, &rl))
 
38
        barf("getrlimit");
 
39
    rl.rlim_cur = rl.rlim_max;
 
40
    if (setrlimit(RLIMIT_CORE, &rl))
 
41
        barf("setrlimit");
 
42
    execv(argv[1], argv+1);
 
43
    fprintf(stderr, "execv: ");
 
44
    barf(argv[1]);
 
45
}