rewrite init to restart failed processes, add file renaming, directory creation, directory renaming, directory removal, add process killing, unify shells, readme changes.
This commit is contained in:
1 parent
f80e66ecde
commit
ddb074f0e0
16 files changed
+476
-641
No files matched your search
+29
-15
@@ -53,23 +53,37 @@ void _start(const char* args)
|
||||
uint32_t h = 0;
|
||||
uint32_t s = 0;
|
||||
|
||||
SysDebugPrint("[init] starting\n");
|
||||
s = SysCreateProcess(args, &h, NULL);
|
||||
if (s != STATUS_SUCCESS) {
|
||||
SysDebugPrint("[init] FATAL: failed to start!\n");
|
||||
char buffer[12];
|
||||
itoa(s, buffer);
|
||||
SysDebugPrint(buffer); SysDebugPrint("\n");
|
||||
SysExitProcess(1);
|
||||
for (;;) {
|
||||
SysDebugPrint("[init] starting\n");
|
||||
s = SysCreateProcess(args, &h, NULL);
|
||||
if (s != STATUS_SUCCESS) {
|
||||
SysDebugPrint("[init] FATAL: failed to start!\n");
|
||||
char buffer[12];
|
||||
itoa(s, buffer);
|
||||
SysDebugPrint(buffer);
|
||||
SysDebugPrint("\n");
|
||||
SysExitProcess(1);
|
||||
}
|
||||
|
||||
SysDebugPrint("[init] waiting\n");
|
||||
s = SysWaitForProcess(h);
|
||||
if (s != STATUS_SUCCESS)
|
||||
SysDebugPrint("[init] WARNING: SysWaitForProcess returned error\n");
|
||||
|
||||
int exitCode = 0;
|
||||
if (SysGetProcessExitCode(h, &exitCode) != STATUS_SUCCESS) {
|
||||
SysDebugPrint("[init] WARNING: failed to read exit code\n");
|
||||
exitCode = 1;
|
||||
}
|
||||
|
||||
SysCloseHandle(h);
|
||||
|
||||
if (exitCode == 0)
|
||||
break;
|
||||
|
||||
SysDebugPrint("[init] child crashed, restarting\n");
|
||||
}
|
||||
|
||||
SysDebugPrint("[init] waiting\n");
|
||||
s = SysWaitForProcess(h);
|
||||
if (s != STATUS_SUCCESS)
|
||||
SysDebugPrint("[init] WARNING: SysWaitForProcess returned error\n");
|
||||
SysCloseHandle(h);
|
||||
|
||||
SysDebugPrint("[init] done\n");
|
||||
|
||||
SysExitProcess(0);
|
||||
}
|
||||
Reference in new issue
Block a user