add pid file and openrc detection

This commit is contained in:
2020-08-05 22:49:31 -04:00
parent 6b771cfa98
commit 1863bd8cc1
2 changed files with 22 additions and 3 deletions

View File

@@ -75,7 +75,26 @@ namespace TUFManager {
if (pid < 0) {
Posix.exit (Posix.EXIT_FAILURE);
}
else if (pid > 0) {
if (pid > 0) {
try {
File file = File.new_for_path ("/run/tufmanager");
if (!file.query_exists ()) {
file.make_directory_with_parents ();
}
file = null;
}
catch (Error e) {
stderr.printf (_ ("Error: %s\n"), e.message);
}
var stream = FileStream.open ("/run/tufmanager/pid", "w");
if (stream == null) {
stderr.printf (_ ("Could not create pid file!\n"));
}
else {
uint32 pidfile = pid;
stream.puts (pidfile.to_string ());
}
Posix.exit (Posix.EXIT_SUCCESS);
}
@@ -100,7 +119,7 @@ namespace TUFManager {
on_bus_acquired,
() => {},
() => {
stderr.printf (_ ("Could not acquire bus name\n"));
stderr.printf (_ ("Could not acquire bus name!\n"));
});
loop = new MainLoop ();