pdb_samba_dsdb: implement PDB_CAP_TRUSTED_DOMAINS_EX related functions
[Samba.git] / lib / util / pidfile.h
blobb1b9f54933927a3656fdd7576d2ef914d1906a5d
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jeremy Allison 2012.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _SAMBA_PIDFILE_H_
21 #define _SAMBA_PIDFILE_H_
23 /**
24 * @file pidfile.h
26 * @brief PID file handling
29 /**
30 * @brief Create a PID file
32 * Opens file, locks it, and writes PID. Returns EACCES or EAGAIN if
33 * another process has the PID file locked. Use unlink(2) and
34 * pidfile_fd_close() to remove the PID file.
36 * @param[in] path PID file name
37 * @param[out] outfd File descriptor of open/locked PID file
38 * @return 0 on success, errno on failure
40 int pidfile_path_create(const char *path, int *outfd);
42 /**
43 * @brief Unlock and close a PID file
45 * @param[in] fd File descriptor of open/locked PID file
47 void pidfile_fd_close(int fd);
49 /**
50 * @brief Check a PID file
52 * PID file name is <piddir>/<name>.pid
54 * @param[in] piddir Directory for PID file
55 * @param[in] name PID file process name
56 * @return PID of active process, 0 if PID file missing/stale/error
58 pid_t pidfile_pid(const char *piddir, const char *name);
60 /**
61 * @brief Create a PID file
63 * Leave PID file open/locked on success, exit on failure. On
64 * success, use pidfile_unlink() to remove PID file before exiting.
66 * PID file name is <piddir>/<name>.pid
68 * @param[in] piddir Directory for PID file
69 * @param[in] name PID file process name
71 void pidfile_create(const char *piddir, const char *name);
73 /**
74 * @brief Remove a PID file
76 * PID file name is <piddir>/<name>.pid
78 * @param[in] piddir Directory for PID file
79 * @param[in] name PID file process name
81 void pidfile_unlink(const char *piddir, const char *name);
83 #endif