2 * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <sys/types.h>
24 #define DAEMON_OPTION_ENUMS \
27 OPT_OVERWRITE_PIDFILE, \
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}
38 #define DAEMON_OPTION_HANDLERS \
48 set_pidfile(optarg); \
51 case OPT_OVERWRITE_PIDFILE: \
52 ignore_existing_pidfile(); \
56 daemon_set_monitor(); \
59 char *make_pidfile_name(const char *name);
60 void set_pidfile(const char *name);
61 const char *get_pidfile(void);
62 void set_no_chdir(void);
63 bool is_chdir_enabled(void);
64 void set_detach(void);
65 bool get_detach(void);
66 void daemon_set_monitor(void);
67 void daemon_save_fd(int fd);
69 void daemonize_start(void);
70 void daemonize_complete(void);
71 void ignore_existing_pidfile(void);
72 void daemon_usage(void);
73 pid_t read_pidfile(const char *name);
74 pid_t read_pidfile_if_exists(const char *name);