feat: make userspace StatusCodes positive; print status text along with code in shell exec; make init return BadInvocation on faulty launch
This commit is contained in:
1 parent
8a3ffb2be1
commit
5e4e8902c2
6 files changed
+96
-41
No files matched your search
@@ -8,6 +8,7 @@
|
||||
#include <montauk/syscall.h>
|
||||
#include <montauk/config.h>
|
||||
#include <montauk/capabilities.h>
|
||||
#include <montauk/statuscodes.h>
|
||||
#include <libc/stdio.h>
|
||||
|
||||
// ---- ANSI color codes ----
|
||||
@@ -204,7 +205,7 @@ const char* getReleaseString(char* buffer, int n) {
|
||||
|
||||
extern "C" void _start() {
|
||||
if (system_already_initialized()) {
|
||||
montauk::exit(1);
|
||||
montauk::exit(montauk::StatusCodes::BadInvocation);
|
||||
}
|
||||
|
||||
char releaseString[128] = "";
|
||||
|
||||
@@ -17,7 +17,9 @@ static bool file_exists(const char* path) {
|
||||
|
||||
// ---- Try to spawn an ELF at the given path ----
|
||||
|
||||
static void print_exit_code(int code) {
|
||||
static void print_exit_code(const int exitCode) {
|
||||
int code = exitCode;
|
||||
|
||||
if (code == 0) return;
|
||||
char buf[16];
|
||||
int n = 0;
|
||||
@@ -36,6 +38,16 @@ static void print_exit_code(int code) {
|
||||
char c[2] = { buf[--n], 0 };
|
||||
montauk::print(c);
|
||||
}
|
||||
|
||||
if (exitCode > 0 && exitCode <= 14) { // 0-14 - current range of status codes within StatusCodes enum
|
||||
const char* statusText = montauk::GetStatusText((montauk::StatusCodes)exitCode);
|
||||
|
||||
if (statusText != nullptr) {
|
||||
montauk::print(" - ");
|
||||
montauk::print(statusText);
|
||||
}
|
||||
}
|
||||
|
||||
montauk::print("]\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user