add pid file and openrc detection
This commit is contained in:
@@ -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 ();
|
||||
|
Reference in New Issue
Block a user