]> git.ipfire.org Git - people/ms/systemd.git/blame - execute.h
unit_merge() needs a proper review
[people/ms/systemd.git] / execute.h
CommitLineData
5cb5a6ff
LP
1/*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3#ifndef fooexecutehfoo
4#define fooexecutehfoo
5
6typedef struct ExecStatus ExecStatus;
7typedef struct ExecCommand ExecCommand;
8typedef struct ExecContext ExecContext;
9
10#include <sys/time.h>
11#include <sys/resource.h>
12#include <sys/capability.h>
13#include <stdbool.h>
14#include <stdio.h>
15
16#include "list.h"
034c6ed7 17#include "util.h"
5cb5a6ff
LP
18
19struct ExecStatus {
20 pid_t pid;
034c6ed7 21 usec_t timestamp;
9152c765
LP
22 int code; /* as in siginfo_t::si_code */
23 int status; /* as in sigingo_t::si_status */
5cb5a6ff
LP
24};
25
26struct ExecCommand {
27 char *path;
28 char **argv;
034c6ed7
LP
29 ExecStatus exec_status;
30 LIST_FIELDS(ExecCommand, command); /* useful for chaining commands */
5cb5a6ff
LP
31};
32
33struct ExecContext {
34 char **environment;
35 mode_t umask;
36 struct rlimit *rlimit[RLIMIT_NLIMITS];
5cb5a6ff
LP
37 int oom_adjust;
38 int nice;
034c6ed7
LP
39 char *directory;
40
41 cap_t capabilities;
42 bool capabilities_set:1;
5cb5a6ff
LP
43
44 /* since resolving these names might might involve socket
45 * connections and we don't want to deadlock ourselves these
46 * names are resolved on execution only. */
47 char *user;
48 char *group;
49 char **supplementary_groups;
50};
51
034c6ed7
LP
52typedef enum ExitStatus {
53 /* EXIT_SUCCESS defined by libc */
54 /* EXIT_FAILURE defined by libc */
55 EXIT_INVALIDARGUMENT = 2,
56 EXIT_NOTIMPLEMENTED = 3,
57 EXIT_NOPERMISSION = 4,
58 EXIT_NOTINSTALLED = 5,
59 EXIT_NOTCONFIGURED = 6,
60 EXIT_NOTRUNNING = 7,
61
62 /* The LSB suggests that error codes >= 200 are "reserved". We
63 * use them here under the assumption that they hence are
64 * unused by init scripts.
65 *
66 * http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html */
67
68 EXIT_CHDIR = 200,
69 EXIT_NICE,
70 EXIT_FDS,
71 EXIT_EXEC,
72 EXIT_MEMORY,
73 EXIT_LIMITS,
309bff19
LP
74 EXIT_OOM_ADJUST,
75 EXIT_SIGNAL_MASK
034c6ed7
LP
76} ExitStatus;
77
78int exec_spawn(const ExecCommand *command, const ExecContext *context, int *fds, unsigned n_fds, pid_t *ret);
5cb5a6ff 79
5cb5a6ff 80void exec_command_free_list(ExecCommand *c);
034c6ed7 81void exec_command_free_array(ExecCommand **c, unsigned n);
5cb5a6ff 82
44d8db9e
LP
83char *exec_command_line(ExecCommand *c);
84void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix);
85void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix);
86
034c6ed7
LP
87void exec_context_init(ExecContext *c);
88void exec_context_done(ExecContext *c);
5cb5a6ff
LP
89void exec_context_dump(ExecContext *c, FILE* f, const char *prefix);
90
034c6ed7 91void exec_status_fill(ExecStatus *s, pid_t pid, int code, int status);
5cb5a6ff
LP
92
93#endif