diff options
Diffstat (limited to 'src/pidfile.h')
-rw-r--r-- | src/pidfile.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/pidfile.h b/src/pidfile.h new file mode 100644 index 0000000..25ddd48 --- /dev/null +++ b/src/pidfile.h @@ -0,0 +1,32 @@ +#ifndef __PIDFILE_H +#define __PIDFILE_H + +#include "port/limits.h" /* for PATH_MAX */ +#include "port/stdbool.h" /* for bool */ + +#include "errors.h" + +#include <sys/types.h> /* for pid_t */ + +struct pidfile_t { + char filename[PATH_MAX]; /**< the filename */ + int fd; /**< file descriptor */ + bool locked; /**< is the pidfile locked? */ + bool running; /**< is another process locking too? */ +}; + +void pidfile_init( struct pidfile_t *pidfile ); + +void pidfile_set_from_daemon_name( struct pidfile_t *pidfile, const char *daemon ); + +void pidfile_set_from_filename( struct pidfile_t *pidfile, const char *filename ); + +bool is_daemon_running( struct pidfile_t *pidfile, pid_t *pid, error_t *error ); + +error_t pidfile_create( struct pidfile_t *pidfile ); + +error_t pidfile_release( struct pidfile_t *pidfile ); + +error_t pidfile_remove( struct pidfile_t *pidfile ); + +#endif /* ifndef __PIDFILE_H */ |