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 ());
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);