mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
SystemServer: Add WorkingDirectory support
Services can now have their initial working directory configured via `SystemServer.ini`. This commit also configures Terminal's working directory to be /home/anon
This commit is contained in:
parent
39c21f368a
commit
bd9f14e27e
4 changed files with 15 additions and 0 deletions
|
@ -188,6 +188,13 @@ void Service::spawn()
|
|||
} else if (m_pid == 0) {
|
||||
// We are the child.
|
||||
|
||||
if (!m_working_directory.is_null()) {
|
||||
if (chdir(m_working_directory.characters()) < 0) {
|
||||
perror("chdir");
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
struct sched_param p;
|
||||
p.sched_priority = m_priority;
|
||||
int rc = sched_setparam(0, &p);
|
||||
|
@ -320,6 +327,8 @@ Service::Service(const Core::ConfigFile& config, const StringView& name)
|
|||
m_socket_permissions = strtol(socket_permissions_string.characters(), nullptr, 8) & 04777;
|
||||
setup_socket();
|
||||
}
|
||||
|
||||
m_working_directory = config.read_entry(name, "WorkingDirectory");
|
||||
}
|
||||
|
||||
void Service::save_to(JsonObject& json)
|
||||
|
@ -352,4 +361,5 @@ void Service::save_to(JsonObject& json)
|
|||
json.set("pid", nullptr);
|
||||
|
||||
json.set("restart_attempts", m_restart_attempts);
|
||||
json.set("working_directory", m_working_directory);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue