move POSIX spawn, exec and child tracking into posixsrv, keep process transactions alive across reconnects and preserve stable PIDs across image replacement, flesh out spawn with ordered file actions, process-group selection and signal inheritance, implement execve with bootstrap validation and rollback before retiring the old process, add vfork children that share the native process while keeping separate POSIX descriptor and signal state, replace local spawn bookkeeping with child reaping, nonblocking and process-group waits and orphan cleanup, add signal dispositions, per-thread masks, pending delivery, process/group signalling and alarms, translate native exceptions into POSIX signals and inherit masks when creating threads, make pipe waits interruptible and raise SIGPIPE for broken pipes, pass arguments and environment into main and add getenv/environ, add direct user APC notifications that can run without an alertable wait, add current-thread capabilities and resume-and-wait, let accepted IPC endpoints open restricted peer process capabilities and preserve caller security during spawn and exec, make process preparation reusable and improve DLL lookup across current, executable and fallback directories, move keyboard repeat into RSSRV so PS/2 and USB share one repeat policy, fix video presentation, report launch failure stages and status codes, mooaaar tests.

This commit is contained in:
maksw committed 2026-09-23 09:39:42 +02:00
1 parent 73abd6f90d
commit 899225f551
57 files changed
+8817 -1216

No files matched your search

+99 -8
View File
@@ -5,9 +5,10 @@
#include <stdint.h>
#include <ntlite/status.h>
#include <ntlite/syscall.h>
#include <ntlite/posix_signal.h>
#define NTL_POSIX_SERVICE_PATH "/Services/posix"
#define NTL_POSIX_PROTOCOL_VERSION 6u
#define NTL_POSIX_PROTOCOL_VERSION 15u
#define NTL_POSIX_REQUEST_FLAG_NONE 0u
@@ -30,15 +31,37 @@
#define NTL_POSIX_OP_CREATE_FD_INHERITANCE 17u
#define NTL_POSIX_OP_IMPORT_FD_INHERITANCE 18u
#define NTL_POSIX_OP_CANCEL_FD_INHERITANCE 19u
#define NTL_POSIX_OP_ARM_FD_INHERITANCE 20u
#define NTL_POSIX_OP_CONSTRUCT_SET_EXECUTABLE 20u
#define NTL_POSIX_OP_CONSTRUCT_WRITE_VECTOR 21u
#define NTL_POSIX_OP_SPAWN_ADD_FILE_ACTION 22u
#define NTL_POSIX_OP_SPAWN_SET_ATTRIBUTES 23u
#define NTL_POSIX_OP_SPAWN_COMMIT 24u
#define NTL_POSIX_OP_BOOTSTRAP_READY 25u
#define NTL_POSIX_OP_WAIT_PROCESS 26u
#define NTL_POSIX_OP_REGISTER_THREAD 27u
#define NTL_POSIX_OP_UNREGISTER_THREAD 28u
#define NTL_POSIX_OP_UPDATE_SIGNAL_MASK 29u
#define NTL_POSIX_OP_SET_SIGNAL_DISPOSITION 30u
#define NTL_POSIX_OP_GET_PENDING_SIGNALS 31u
#define NTL_POSIX_OP_SEND_SIGNAL 32u
#define NTL_POSIX_OP_SET_ALARM 33u
#define NTL_POSIX_OP_EXEC_COMMIT 34u
#define NTL_POSIX_OP_VFORK_BEGIN 35u
#define NTL_POSIX_OP_VFORK_ATTACH 36u
#define NTL_POSIX_OP_VFORK_CANCEL 37u
#define NTL_POSIX_OP_VFORK_EXIT 38u
#define NTL_POSIX_TRANSACTION_NONE 0u
#define NTL_POSIX_TRANSACTION_SPAWN 1u
#define NTL_POSIX_TRANSACTION_EXEC 2u
#define NTL_POSIX_PROCESS_STATE_NONE 0u
#define NTL_POSIX_PROCESS_STATE_RUNNING 1u
#define NTL_POSIX_PROCESS_STATE_EXITED 2u
#define NTL_POSIX_PROCESS_STATE_NONE 0u
#define NTL_POSIX_PROCESS_STATE_CONSTRUCTING 1u
#define NTL_POSIX_PROCESS_STATE_RUNNING 2u
#define NTL_POSIX_PROCESS_STATE_EXEC_PREPARING 3u
#define NTL_POSIX_PROCESS_STATE_EXEC_COMMITTING 4u
#define NTL_POSIX_PROCESS_STATE_EXITED 5u
#define NTL_POSIX_PROCESS_STATE_VFORK_BORROWED 6u
#define NTL_POSIX_LOOKUP_NONE 0u
#define NTL_POSIX_LOOKUP_BY_ID 1u
@@ -68,8 +91,12 @@
#define NTL_POSIX_OPEN_STATUS_ACCMODE 0x0003u
#define NTL_POSIX_OPEN_STATUS_APPEND 0x0400u
#define NTL_POSIX_OPEN_STATUS_NONBLOCK 0x0800u
#define NTL_POSIX_OPEN_CREATE 0x0040u
#define NTL_POSIX_OPEN_TRUNCATE 0x0200u
#define NTL_POSIX_OPEN_STATUS_VALID_MASK \
(NTL_POSIX_OPEN_STATUS_ACCMODE | NTL_POSIX_OPEN_STATUS_APPEND | NTL_POSIX_OPEN_STATUS_NONBLOCK)
#define NTL_POSIX_SPAWN_OPEN_VALID_MASK \
(NTL_POSIX_OPEN_STATUS_VALID_MASK | NTL_POSIX_OPEN_CREATE | NTL_POSIX_OPEN_TRUNCATE)
#define NTL_POSIX_SHARED_OPEN_MAGIC 0x31444F50u
#define NTL_POSIX_SHARED_OPEN_VERSION 2u
@@ -80,6 +107,30 @@
#define NTL_POSIX_FD_DESCRIPTOR_CLOEXEC 0x00000001u
#define NTL_POSIX_FD_HANDLE_NONE UINT32_MAX
#define NTL_POSIX_CONSTRUCT_VECTOR_ARGUMENT 1u
#define NTL_POSIX_CONSTRUCT_VECTOR_ENVIRONMENT 2u
#define NTL_POSIX_CONSTRUCT_VECTOR_CHUNK_FINAL 0x00000001u
#define NTL_POSIX_CONSTRUCT_VECTOR_MAX 1024u
#define NTL_POSIX_CONSTRUCT_DATA_MAX (1024u * 1024u)
#define NTL_POSIX_SPAWN_ACTION_CLOSE 1u
#define NTL_POSIX_SPAWN_ACTION_DUP2 2u
#define NTL_POSIX_SPAWN_ACTION_OPEN 3u
#define NTL_POSIX_SPAWN_ACTION_MAX 64u
#define NTL_POSIX_SPAWN_ATTR_SETPGROUP 0x00000001u
#define NTL_POSIX_SPAWN_ATTR_SETSIGMASK 0x00000002u
#define NTL_POSIX_SPAWN_ATTR_SETSIGDEF 0x00000004u
#define NTL_POSIX_WAIT_NOHANG 0x00000001u
#define NTL_POSIX_SIGNAL_DISPOSITION_DEFAULT 0u
#define NTL_POSIX_SIGNAL_DISPOSITION_IGNORE 1u
#define NTL_POSIX_SIGNAL_DISPOSITION_CAUGHT 2u
#define NTL_POSIX_SIGNAL_ROUTE_PROCESS 1u
#define NTL_POSIX_SIGNAL_ROUTE_THREAD 2u
typedef struct NTL_POSIX_FD_MANIFEST_ENTRY {
int32_t Descriptor;
uint32_t DescriptorFlags;
@@ -111,11 +162,11 @@ typedef struct NTL_POSIX_SHARED_OPEN_DESCRIPTION {
uint64_t SharedObjectData;
} NTL_POSIX_SHARED_OPEN_DESCRIPTION;
// Future server-owned spawn/exec builders place this opaque personality payload
// Server-owned spawn/exec builders place this opaque personality payload
// in the generic userspace process-loader startup data. Zero token/PID/generation
// means an ordinary process is self-registering for the first time.
#define NTL_POSIX_BOOTSTRAP_MAGIC 0x3258504Eu
#define NTL_POSIX_BOOTSTRAP_VERSION 2u
#define NTL_POSIX_BOOTSTRAP_VERSION 3u
typedef struct NTL_POSIX_BOOTSTRAP_DATA {
uint32_t Magic;
@@ -126,6 +177,8 @@ typedef struct NTL_POSIX_BOOTSTRAP_DATA {
uint32_t PosixPid;
uint32_t Generation;
uint64_t FdInheritanceToken;
uint64_t InitialSignalMask;
uint64_t IgnoredSignals;
} NTL_POSIX_BOOTSTRAP_DATA;
// Requests remain fixed-size through P4 open-description control. Later spawn/exec
@@ -155,7 +208,31 @@ typedef struct NTL_POSIX_REQUEST {
uint32_t FdInheritanceIndex;
uint32_t FdInheritanceCount;
uint32_t FdInheritanceFlags;
uint32_t Reserved[2];
uint32_t ConstructionVectorKind;
uint32_t ConstructionVectorIndex;
uint32_t ConstructionVectorOffset;
uint32_t ConstructionVectorFlags;
uint32_t SpawnActionKind;
int32_t SpawnFileDescriptor;
int32_t SpawnNewFileDescriptor;
uint32_t SpawnOpenFlags;
uint32_t SpawnOpenMode;
uint32_t SpawnAttributeFlags;
uint64_t SpawnSignalMask;
uint64_t SpawnSignalDefaultMask;
int32_t WaitPid;
uint32_t WaitOptions;
int32_t SignalTargetPid;
int32_t SignalNumber;
uint32_t SignalDisposition;
uint32_t SignalReserved;
uint64_t SignalMask;
uint64_t SignalApcRoutine;
uint32_t AlarmSeconds;
uint32_t AlarmReserved;
uint64_t VforkToken;
int32_t VforkExitCode;
uint32_t VforkReserved;
NTL_POSIX_FD_MANIFEST_ENTRY FdManifest[NTL_POSIX_FD_INHERIT_MAX];
char Name[NTL_POSIX_IDENTITY_NAME_MAX + 1u];
char Path[SYS_PATH_MAX + 1u];
@@ -175,10 +252,19 @@ typedef struct NTL_POSIX_REPLY {
uint32_t ActiveTransactions;
uint32_t TransactionCapacity;
uint32_t PosixPid;
uint32_t SpawnedPosixPid;
int32_t WaitedPosixPid;
int32_t ExitCode;
uint32_t NativeGeneration;
uint32_t ProcessState;
uint32_t RegisteredProcesses;
uint32_t RegisteredOpenDescriptions;
uint32_t RegisteredThreads;
uint32_t SignalReserved;
uint64_t PendingSignals;
uint32_t AlarmRemainingSeconds;
uint32_t AlarmReserved;
uint64_t VforkToken;
uint32_t OpenDescriptionType;
uint32_t OpenStatusFlags;
uint64_t OpenDescriptionId;
@@ -217,3 +303,8 @@ typedef struct NTL_POSIX_REPLY {
char Shell[NTL_POSIX_IDENTITY_SHELL_MAX + 1u];
char CurrentDirectory[SYS_PATH_MAX + 1u];
} NTL_POSIX_REPLY;
_Static_assert(sizeof(NTL_POSIX_REQUEST) <= SYS_PORT_MAX_INLINE_BYTES,
"POSIX request must fit in one Port inline payload.");
_Static_assert(sizeof(NTL_POSIX_REPLY) <= SYS_PORT_MAX_INLINE_BYTES,
"POSIX reply must fit in one Port inline payload.");