1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 03:58:12 +00:00

SystemServer: Use dbg() instead of dbgprintf()

This commit is contained in:
Conrad Pankoff 2019-09-03 23:44:12 +10:00 committed by Andreas Kling
parent a8bd43588b
commit 6fb7eeb81a

View file

@ -13,21 +13,21 @@ void start_process(const String& program, const Vector<String>& arguments, int p
pid_t pid = 0; pid_t pid = 0;
while (true) { while (true) {
dbgprintf("Forking for %s...\n", program.characters()); dbg() << "Forking for " << program << "...";
int pid = fork(); int pid = fork();
if (pid < 0) { if (pid < 0) {
dbgprintf("Fork %s failed! %s\n", program.characters(), strerror(errno)); dbg() << "Fork " << program << " failed! " << strerror(errno);
continue; continue;
} else if (pid > 0) { } else if (pid > 0) {
// parent... // parent...
dbgprintf("Process %s hopefully started with priority %d...\n", program.characters(), prio); dbg() << "Process " << program << " hopefully started with priority " << prio << "...";
return; return;
} }
break; break;
} }
while (true) { while (true) {
dbgprintf("Executing for %s... at prio %d\n", program.characters(), prio); dbg() << "Executing for " << program << "... at prio " << 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);
@ -47,7 +47,7 @@ void start_process(const String& program, const Vector<String>& arguments, int p
progv[arguments.size() + 1] = nullptr; progv[arguments.size() + 1] = nullptr;
ret = execv(progv[0], progv); ret = execv(progv[0], progv);
if (ret < 0) { if (ret < 0) {
dbgprintf("Exec %s failed! %s", progv[0], strerror(errno)); dbg() << "Exec " << progv[0] << " failed! " << strerror(errno);
continue; continue;
} }
break; break;
@ -58,23 +58,23 @@ static void check_for_test_mode()
{ {
CFile f("/proc/cmdline"); CFile f("/proc/cmdline");
if (!f.open(CIODevice::ReadOnly)) { if (!f.open(CIODevice::ReadOnly)) {
dbgprintf("Failed to read command line: %s\n", f.error_string()); dbg() << "Failed to read command line: " << f.error_string();
ASSERT(false); ASSERT(false);
} }
const String cmd = String::copy(f.read_all()); const String cmd = String::copy(f.read_all());
dbgprintf("Read command line: %s\n", cmd.characters()); dbg() << "Read command line: " << cmd;
if (cmd.matches("*testmode=1*")) { if (cmd.matches("*testmode=1*")) {
// Eventually, we should run a test binary and wait for it to finish // Eventually, we should run a test binary and wait for it to finish
// before shutting down. But this is good enough for now. // before shutting down. But this is good enough for now.
dbgprintf("Waiting for testmode shutdown...\n"); dbg() << "Waiting for testmode shutdown...";
sleep(5); sleep(5);
dbgprintf("Shutting down due to testmode...\n"); dbg() << "Shutting down due to testmode...";
if (fork() == 0) { if (fork() == 0) {
execl("/bin/shutdown", "/bin/shutdown", "-n", nullptr); execl("/bin/shutdown", "/bin/shutdown", "-n", nullptr);
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }
} else { } else {
dbgprintf("Continuing normally\n"); dbg() << "Continuing normally";
} }
} }