prog.h
2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2009, 2011-2012, 2014 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Mailutils is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _MAILUTILS_PROG_H
#define _MAILUTILS_PROG_H
#include <sys/time.h>
#include <sys/resource.h>
#include <mailutils/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MU_PROG_LIMIT_AS 0
#define MU_PROG_LIMIT_CPU 1
#define MU_PROG_LIMIT_DATA 2
#define MU_PROG_LIMIT_FSIZE 3
#define MU_PROG_LIMIT_NPROC 4
#define MU_PROG_LIMIT_CORE 5
#define MU_PROG_LIMIT_MEMLOCK 6
#define MU_PROG_LIMIT_NOFILE 7
#define MU_PROG_LIMIT_RSS 8
#define MU_PROG_LIMIT_STACK 9
#define _MU_PROG_LIMIT_MAX 10
#define MU_PROG_HINT_WORKDIR 0x0001 /* Workdir is set */
#define MU_PROG_HINT_PRIO 0x0002 /* Prio is set */
#define MU_PROG_HINT_INPUT 0x0004 /* Input stream is set */
#define MU_PROG_HINT_UID 0x0008 /* Uid is set */
#define MU_PROG_HINT_GID 0x0010 /* Supplementary gids are set */
#define MU_PROG_HINT_ERRTOOUT 0x0020 /* Redirect stderr to stdout */
#define MU_PROG_HINT_ERRTOSTREAM 0x0040 /* Redirect stderr to errstream */
#define MU_PROG_HINT_IGNOREFAIL 0x0080 /* Ignore hint setup failures */
#define _MU_PROG_HINT_MASK 0x00ff
#define MU_PROG_HINT_LIMIT(n) (0x100 << (n)) /* MU_PROG_LIMIT_n is set */
struct mu_prog_hints
{
char *mu_prog_workdir; /* Working directory */
uid_t mu_prog_uid; /* Run as this user */
gid_t *mu_prog_gidv; /* Array of supplementary gids */
size_t mu_prog_gidc; /* Number of elements in gidv */
rlim_t mu_prog_limit[_MU_PROG_LIMIT_MAX]; /* Limits */
int mu_prog_prio; /* Scheduling priority */
mu_stream_t mu_prog_input; /* Input stream */
mu_stream_t mu_prog_error; /* Error stream */
};
int mu_prog_stream_create (mu_stream_t *pstream,
const char *progname,
size_t argc, char **argv,
int hflags,
struct mu_prog_hints *hints,
int flags);
int mu_command_stream_create (mu_stream_t *pstream, const char *command,
int flags);
#ifdef __cplusplus
}
#endif
#endif