PID-file management.
More...
#include <glib.h>
Go to the source code of this file.
PID-file management.
Definition in file pidfile.h.
◆ pidfile_create()
| int pidfile_create |
( |
gchar * |
pid_file_path | ) |
|
Create a PID-file.
A standard PID file will be created for the given path.
- Parameters
-
| [in] | pid_file_path | The full path of the pid file. E.g. "/tmp/service1.pid" |
- Returns
- 0 for success, anything else indicates an error.
Definition at line 40 of file pidfile.c.
45 if (pid_file_path == NULL)
48 copy = g_strdup (pid_file_path);
53 if (g_mkdir_with_parents (dir, 0755))
56 g_warning (
"Failed to create PID file directory %s: %s", dir,
64 pidfile = g_fopen (pid_file_path,
"w");
68 g_critical (
"%s: failed to open pidfile %s: %s\n", __func__,
69 pid_file_path, strerror (errno));
74 g_fprintf (pidfile,
"%d\n", getpid ());
◆ pidfile_remove()
| void pidfile_remove |
( |
gchar * |
pid_file_path | ) |
|
Remove PID file.
- Parameters
-
| [in] | pid_file_path | The full path of the pid file. E.g. "/tmp/service1.pid" |
Definition at line 87 of file pidfile.c.
89 gchar *pidfile_contents;
91 if (g_file_get_contents (pid_file_path, &pidfile_contents, NULL, NULL))
93 int pid = atoi (pidfile_contents);
97 g_unlink (pid_file_path);
99 g_free (pidfile_contents);