summaryrefslogtreecommitdiff
path: root/src/util/virpidfile.h
blob: 5d31f02702a21a1b0c3f78a33132b2fff28fe44d (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * virpidfile.h: manipulation of pidfiles
 *
 * Copyright (C) 2010-2011, 2014 Red Hat, Inc.
 * Copyright (C) 2006, 2007 Binary Karma
 * Copyright (C) 2006 Shuveb Hussain
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 */

#pragma once

#include <sys/types.h>
#include "internal.h"

char *virPidFileBuildPath(const char *dir,
                          const char *name);

int virPidFileWritePath(const char *path,
                        pid_t pid) G_GNUC_WARN_UNUSED_RESULT;
int virPidFileWrite(const char *dir,
                    const char *name,
                    pid_t pid) G_GNUC_WARN_UNUSED_RESULT;

int virPidFileReadPath(const char *path,
                       pid_t *pid) G_GNUC_WARN_UNUSED_RESULT;
int virPidFileRead(const char *dir,
                   const char *name,
                   pid_t *pid) G_GNUC_WARN_UNUSED_RESULT;

int virPidFileReadPathIfAlive(const char *path,
                              pid_t *pid,
                              const char *binpath) G_GNUC_WARN_UNUSED_RESULT;
int virPidFileReadIfAlive(const char *dir,
                          const char *name,
                          pid_t *pid,
                          const char *binpath) G_GNUC_WARN_UNUSED_RESULT;
int virPidFileReadPathIfLocked(const char *path,
                               pid_t *pid)  G_GNUC_WARN_UNUSED_RESULT;

int virPidFileDeletePath(const char *path);
int virPidFileDelete(const char *dir,
                     const char *name);


int virPidFileAcquirePathFull(const char *path,
                              bool waitForLock,
                              bool quiet,
                              pid_t pid) G_GNUC_WARN_UNUSED_RESULT;
int virPidFileAcquirePath(const char *path,
                          pid_t pid) G_GNUC_WARN_UNUSED_RESULT;
int virPidFileAcquire(const char *dir,
                      const char *name,
                      pid_t pid) G_GNUC_WARN_UNUSED_RESULT;

int virPidFileReleasePath(const char *path,
                          int fd);
int virPidFileRelease(const char *dir,
                      const char *name,
                      int fd);

int virPidFileConstructPath(bool privileged,
                            const char *statedir,
                            const char *progname,
                            char **pidfile);

int virPidFileForceCleanupPathFull(const char *path,
                                   bool group) ATTRIBUTE_NONNULL(1);
int virPidFileForceCleanupPath(const char *path) ATTRIBUTE_NONNULL(1);