build.bat can create the image if missing, split the shell into native, posix and win32, clean up the build by moving executables into directories, the bootloader is no longer responsible to resolve drivers, fix ResolvePath, every process gets a copy of a module (dll), the child always inherits the cwd, fix function exports in posix, add unlink and exit to posix, add path translator to win32, first bugcheck.

This commit is contained in:
maksw committed 2026-05-13 09:24:16 +02:00
1 parent 0c7f461c6d
commit f80e66ecde
38 files changed
+1620 -462

No files matched your search

+8 -11
View File
@@ -1,17 +1,10 @@
// posix_proc.c - posix_spawn, waitpid, getpid
#include <stddef.h>
#include <string.h>
#include <syscall.h>
#include "posix.h"
#include "posix_path.h"
extern uint32_t SysGetCurrentPid(void);
extern uint32_t SysCreateProcess(const char* path, uint32_t* handleOut,
const char* cmdline);
extern uint32_t SysWaitForProcess(uint32_t handle);
extern uint32_t SysGetProcessExitCode(uint32_t handle, int* exitCodeOut);
extern uint32_t SysGetProcessPid(uint32_t handle, uint32_t* pidOut);
extern void SysCloseHandle(uint32_t handle);
// pid -> proc handle table (user-mode side, for waitpid)
#define PROC_TABLE_SIZE 32
typedef struct {
@@ -69,11 +62,11 @@ static void BuildCmdline(char* const argv[], char* out, size_t outSize) {
// POSIX API
// ---------------------------------------------------------------------------
pid_t getpid(void) {
__declspec(dllexport) pid_t getpid(void) {
return (pid_t)SysGetCurrentPid();
}
int posix_spawn(pid_t* pidOut,
__declspec(dllexport) int posix_spawn(pid_t* pidOut,
const char* path,
const posix_spawn_file_actions_t* file_actions, // ignored v1
const posix_spawnattr_t* attrp, // ignored v1
@@ -108,7 +101,7 @@ int posix_spawn(pid_t* pidOut,
}
// options: WNOHANG not supported in v1 (always blocks).
pid_t waitpid(pid_t pid, int* status, int options) {
__declspec(dllexport) pid_t waitpid(pid_t pid, int* status, int options) {
(void)options;
uint32_t handle = ProcTableFind(pid);
@@ -124,3 +117,7 @@ pid_t waitpid(pid_t pid, int* status, int options) {
ProcTableRemove(pid);
return pid;
}
__declspec(dllexport) void exit(int status) {
SysExitProcess(status);
}