summaryrefslogtreecommitdiffstats
path: root/ctdb/common/pidfile.h
blob: bc4e3a7339f49d6d8d4d03af253ccc73c939cf8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
   Create and remove pidfile

   Copyright (C) Amitay Isaacs  2016

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __CTDB_PIDFILE_H__
#define __CTDB_PIDFILE_H__

#include <talloc.h>

/**
 * @file pidfile.h
 *
 * @brief Routines to manage PID file
 */

/**
 * @brief Abstract struct to store pidfile details
 */
struct pidfile_context;

/**
 * @brief Create a PID file
 *
 * This creates a PID file, locks it, and writes PID.
 *
 * @param[in] mem_ctx Talloc memory context
 * @param[in] pidfile Path of PID file
 * @param[out] result Pidfile context
 * @return 0 on success, errno on failure
 *
 * Freeing the pidfile_context, will delete the pidfile.
 */
int pidfile_context_create(TALLOC_CTX *mem_ctx, const char *pidfile,
			   struct pidfile_context **result);

#endif /* __CTDB_PIDFILE_H__ */