ddos/set_proc_limit.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Fri, 27 Dec 2013 16:00:09 +0100
changeset 167 7c6b221900bf
parent 77 49e0babccb23
permissions -rw-r--r--
Proper Datatypes to leave the 80's
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
68
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
/**
77
49e0babccb23 HEADER TAGS
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 68
diff changeset
     2
 * ddos/set_limit.c
68
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     3
 * Copyright (C) 2008 Markus Broeker
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     4
 */
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     5
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     6
#include <sys/resource.h>
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     7
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     8
int set_proc_limit (int processes)
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     9
{
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    10
    struct rlimit rlim;
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    11
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    12
    rlim.rlim_cur = processes;
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    13
    rlim.rlim_max = processes + 24;
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    15
    return setrlimit (RLIMIT_NPROC, &rlim);
d549894aa6a9 Trivial Changes
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
}