s3: smbd: Sanitize any "server" and "share" components of SMB1 DFS paths to remove...
[Samba.git] / lib / util / pidfile.h
blob6f345a9d95d723dccad4d0efc8b8d3503341774f
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 EAGAIN if another
33 * 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 * @param[out] existing_pid Return existing PID on EAGAIN
39 * @return 0 on success, errno on failure
41 int pidfile_path_create(
42 const char *path, int *outfd, pid_t *existing_pid);
44 /**
45 * @brief Unlock and close a PID file
47 * @param[in] fd File descriptor of open/locked PID file
49 void pidfile_fd_close(int fd);
51 /**
52 * @brief Check a PID file
54 * PID file name is <piddir>/<name>.pid
56 * @param[in] piddir Directory for PID file
57 * @param[in] name PID file process name
58 * @return PID of active process, 0 if PID file missing/stale/error
60 pid_t pidfile_pid(const char *piddir, const char *name);
62 /**
63 * @brief Create a PID file
65 * Leave PID file open/locked on success, exit on failure. On
66 * success, use pidfile_unlink() to remove PID file before exiting.
68 * PID file name is <piddir>/<name>.pid
70 * @param[in] piddir Directory for PID file
71 * @param[in] name PID file process name
73 void pidfile_create(const char *piddir, const char *name);
75 /**
76 * @brief Remove a PID file
78 * PID file name is <piddir>/<name>.pid
80 * @param[in] piddir Directory for PID file
81 * @param[in] name PID file process name
83 void pidfile_unlink(const char *piddir, const char *name);
85 #endif