mirror of
https://github.com/RGBCube/serenity
synced 2025-05-26 01:55:08 +00:00
SystemServer: Allow more arguments for startup processes
This commit is contained in:
parent
a3468dc993
commit
a8bd43588b
1 changed files with 21 additions and 20 deletions
|
@ -8,26 +8,26 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void start_process(const char* prog, const char* arg, int prio, const char* tty = nullptr)
|
void start_process(const String& program, const Vector<String>& arguments, int prio, const char* tty = nullptr)
|
||||||
{
|
{
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
dbgprintf("Forking for %s...\n", prog);
|
dbgprintf("Forking for %s...\n", program.characters());
|
||||||
int pid = fork();
|
int pid = fork();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
dbgprintf("Fork %s failed! %s\n", prog, strerror(errno));
|
dbgprintf("Fork %s failed! %s\n", program.characters(), strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
} else if (pid > 0) {
|
} else if (pid > 0) {
|
||||||
// parent...
|
// parent...
|
||||||
dbgprintf("Process %s hopefully started with priority %d...\n", prog, prio);
|
dbgprintf("Process %s hopefully started with priority %d...\n", program.characters(), prio);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
dbgprintf("Executing for %s... at prio %d\n", prog, prio);
|
dbgprintf("Executing for %s... at prio %d\n", program.characters(), prio);
|
||||||
struct sched_param p;
|
struct sched_param p;
|
||||||
p.sched_priority = prio;
|
p.sched_priority = prio;
|
||||||
int ret = sched_setparam(pid, &p);
|
int ret = sched_setparam(pid, &p);
|
||||||
|
@ -41,12 +41,13 @@ void start_process(const char* prog, const char* arg, int prio, const char* tty
|
||||||
}
|
}
|
||||||
|
|
||||||
char* progv[256];
|
char* progv[256];
|
||||||
progv[0] = const_cast<char*>(prog);
|
progv[0] = const_cast<char*>(program.characters());
|
||||||
progv[1] = const_cast<char*>(arg);
|
for (int i = 0; i < arguments.size() && i < 254; i++)
|
||||||
progv[2] = nullptr;
|
progv[i+1] = const_cast<char*>(arguments[i].characters());
|
||||||
ret = execv(prog, progv);
|
progv[arguments.size() + 1] = nullptr;
|
||||||
|
ret = execv(progv[0], progv);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dbgprintf("Exec %s failed! %s", prog, strerror(errno));
|
dbgprintf("Exec %s failed! %s", progv[0], strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -83,24 +84,24 @@ int main(int, char**)
|
||||||
int highest_prio = sched_get_priority_max(SCHED_OTHER);
|
int highest_prio = sched_get_priority_max(SCHED_OTHER);
|
||||||
|
|
||||||
// Mount the filesystems.
|
// Mount the filesystems.
|
||||||
start_process("/bin/mount", "-a", highest_prio);
|
start_process("/bin/mount", { "-a" }, highest_prio);
|
||||||
wait(nullptr);
|
wait(nullptr);
|
||||||
|
|
||||||
// NOTE: We don't start anything on tty0 since that's the "active" TTY while WindowServer is up.
|
// NOTE: We don't start anything on tty0 since that's the "active" TTY while WindowServer is up.
|
||||||
start_process("/bin/TTYServer", "tty1", highest_prio, "/dev/tty1");
|
start_process("/bin/TTYServer", { "tty1" }, highest_prio, "/dev/tty1");
|
||||||
start_process("/bin/TTYServer", "tty2", highest_prio, "/dev/tty2");
|
start_process("/bin/TTYServer", { "tty2" }, highest_prio, "/dev/tty2");
|
||||||
start_process("/bin/TTYServer", "tty3", highest_prio, "/dev/tty3");
|
start_process("/bin/TTYServer", { "tty3" }, highest_prio, "/dev/tty3");
|
||||||
|
|
||||||
// Drop privileges.
|
// Drop privileges.
|
||||||
setuid(100);
|
setuid(100);
|
||||||
setgid(100);
|
setgid(100);
|
||||||
|
|
||||||
start_process("/bin/LookupServer", nullptr, lowest_prio);
|
start_process("/bin/LookupServer", {}, lowest_prio);
|
||||||
start_process("/bin/WindowServer", nullptr, highest_prio);
|
start_process("/bin/WindowServer", {}, highest_prio);
|
||||||
start_process("/bin/AudioServer", nullptr, highest_prio);
|
start_process("/bin/AudioServer", {}, highest_prio);
|
||||||
start_process("/bin/Taskbar", nullptr, highest_prio);
|
start_process("/bin/Taskbar", {}, highest_prio);
|
||||||
start_process("/bin/Terminal", nullptr, highest_prio - 1);
|
start_process("/bin/Terminal", {}, highest_prio - 1);
|
||||||
start_process("/bin/Launcher", nullptr, highest_prio);
|
start_process("/bin/Launcher", {}, highest_prio);
|
||||||
|
|
||||||
// This won't return if we're in test mode.
|
// This won't return if we're in test mode.
|
||||||
check_for_test_mode();
|
check_for_test_mode();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue