]>
Commit | Line | Data |
---|---|---|
064af421 | 1 | /* |
8274ae95 | 2 | * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. |
064af421 | 3 | * |
a14bc59f BP |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at: | |
064af421 | 7 | * |
a14bc59f BP |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
064af421 BP |
15 | */ |
16 | ||
17 | #ifndef DAEMON_H | |
18 | #define DAEMON_H 1 | |
19 | ||
91a1e24d | 20 | #include <limits.h> |
064af421 BP |
21 | #include <stdbool.h> |
22 | #include <sys/types.h> | |
23 | ||
8274ae95 BP |
24 | #define DAEMON_OPTION_ENUMS \ |
25 | OPT_DETACH, \ | |
26 | OPT_NO_CHDIR, \ | |
27 | OPT_OVERWRITE_PIDFILE, \ | |
28 | OPT_PIDFILE, \ | |
ff8decf1 | 29 | OPT_MONITOR |
91a1e24d | 30 | |
e3c17733 BP |
31 | #define DAEMON_LONG_OPTIONS \ |
32 | {"detach", no_argument, NULL, OPT_DETACH}, \ | |
33 | {"no-chdir", no_argument, NULL, OPT_NO_CHDIR}, \ | |
34 | {"pidfile", optional_argument, NULL, OPT_PIDFILE}, \ | |
35 | {"overwrite-pidfile", no_argument, NULL, OPT_OVERWRITE_PIDFILE}, \ | |
36 | {"monitor", no_argument, NULL, OPT_MONITOR} | |
064af421 BP |
37 | |
38 | #define DAEMON_OPTION_HANDLERS \ | |
e7bd7d78 | 39 | case OPT_DETACH: \ |
064af421 BP |
40 | set_detach(); \ |
41 | break; \ | |
42 | \ | |
91a1e24d JP |
43 | case OPT_NO_CHDIR: \ |
44 | set_no_chdir(); \ | |
45 | break; \ | |
46 | \ | |
e7bd7d78 | 47 | case OPT_PIDFILE: \ |
064af421 BP |
48 | set_pidfile(optarg); \ |
49 | break; \ | |
50 | \ | |
e7bd7d78 | 51 | case OPT_OVERWRITE_PIDFILE: \ |
064af421 | 52 | ignore_existing_pidfile(); \ |
ff8decf1 BP |
53 | break; \ |
54 | \ | |
55 | case OPT_MONITOR: \ | |
56 | daemon_set_monitor(); \ | |
064af421 BP |
57 | break; |
58 | ||
59 | char *make_pidfile_name(const char *name); | |
60 | void set_pidfile(const char *name); | |
61 | const char *get_pidfile(void); | |
91a1e24d | 62 | void set_no_chdir(void); |
eb077b26 | 63 | bool is_chdir_enabled(void); |
064af421 | 64 | void set_detach(void); |
eb077b26 | 65 | bool get_detach(void); |
ff8decf1 | 66 | void daemon_set_monitor(void); |
064af421 | 67 | void daemonize(void); |
95440284 BP |
68 | void daemonize_start(void); |
69 | void daemonize_complete(void); | |
064af421 BP |
70 | void ignore_existing_pidfile(void); |
71 | void daemon_usage(void); | |
72 | pid_t read_pidfile(const char *name); | |
18e124a2 | 73 | pid_t read_pidfile_if_exists(const char *name); |
064af421 BP |
74 | |
75 | #endif /* daemon.h */ |