Add pidfile functions

Taken from FreeBSD.

Remove MAXPATHLEN from ‘struct pidfh’ and allocate pf_path dynamically,
as some systems do not have such limits. Use dev_t instead of __dev_t.
Replace EDOOFUS with EINVAL.
This commit is contained in:
Guillem Jover
2010-01-10 00:10:21 +01:00
parent 98a2479f0b
commit 2a81893cc0
5 changed files with 528 additions and 0 deletions

View File

@@ -42,12 +42,24 @@
#include <features.h>
#include <sys/types.h>
/* for pidfile.c */
struct pidfh {
int pf_fd;
char *pf_path;
dev_t pf_dev;
ino_t pf_ino;
};
__BEGIN_DECLS
int humanize_number(char *buf, size_t len, int64_t bytes,
const char *suffix, int scale, int flags);
int flopen(const char *_path, int _flags, ...);
struct pidfh *pidfile_open(const char *path, mode_t mode, pid_t *pidptr);
int pidfile_write(struct pidfh *pfh);
int pidfile_close(struct pidfh *pfh);
int pidfile_remove(struct pidfh *pfh);
__END_DECLS
/* humanize_number(3) */