chiark / gitweb /
service: actually leave watchdog enabled in the states where it matters
[elogind.git] / src / core / scope.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2013 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 typedef struct Scope Scope;
25
26 #include "unit.h"
27 #include "kill.h"
28
29 typedef enum ScopeState {
30         SCOPE_DEAD,
31         SCOPE_RUNNING,
32         SCOPE_STOP_SIGTERM,
33         SCOPE_STOP_SIGKILL,
34         SCOPE_FAILED,
35         _SCOPE_STATE_MAX,
36         _SCOPE_STATE_INVALID = -1
37 } ScopeState;
38
39 typedef enum ScopeResult {
40         SCOPE_SUCCESS,
41         SCOPE_FAILURE_RESOURCES,
42         SCOPE_FAILURE_TIMEOUT,
43         _SCOPE_RESULT_MAX,
44         _SCOPE_RESULT_INVALID = -1
45 } ScopeResult;
46
47 struct Scope {
48         Unit meta;
49
50         CGroupContext cgroup_context;
51         KillContext kill_context;
52
53         ScopeState state, deserialized_state;
54         ScopeResult result;
55
56         usec_t timeout_stop_usec;
57
58         Set *pids;
59
60         sd_event_source *timer_event_source;
61 };
62
63 extern const UnitVTable scope_vtable;
64
65 const char* scope_state_to_string(ScopeState i) _const_;
66 ScopeState scope_state_from_string(const char *s) _pure_;
67
68 const char* scope_result_to_string(ScopeResult i) _const_;
69 ScopeResult scope_result_from_string(const char *s) _pure_;