[FEATURE] Run ordinary C programs through explicit native startup #9

Open
opened 2026-10-26 10:26:37 +01:00 by erikinkinen · 1 comment
Owner

Problem and motivation

The process heap does not yet provide ordinary C startup. C programs need their authenticated launch arguments and environment, a real main call and defined normal or immediate exit.

Proposed behavior and scope

Add an explicit process-root startup companion using LCS1 and the shared C/Rust heap. Construct mutable counted argv, including argc == 0, and the exported environment. Provide environ, getenv, counted atexit, exit and _Exit.

Preserve existing CLI admission rules. Keep command identity independent of argv[0]; do not invent a Linux initial stack or auxiliary data.

Authority, security and reliability

Retain launch, stream, thread and heap owners through the last reader and the genuine whole-process terminal fence. Environment strings grant no authority. Run callbacks outside registry locks, prevent replay after an interrupted drain and preserve uncertain terminal calls without retry. Process termination and resource reclamation remain distinct.

Acceptance criteria

  • Admit ordinary C startup from the authenticated launch packet, with mutable arguments, exported environment and no fixed argument or registration count limit.
  • Call C main once, including zero arguments, and expose the selected environment without host lookup.
  • Implement ordered exit handlers, concurrent registration and distinct normal/immediate exit paths with retained failure custody.
  • Use the original process-group terminal backend and retain backing through sibling readers and shutdown.
  • Add the original-source producer, C consumer, regression controls, guest scenarios and component/manual contracts.
  • Demonstrate the native startup path; keep full sysroot, auxiliary data, FILE buffering and imported-tool acceptance separate.

Alternatives and tradeoffs

Reuse the existing launch ABI and explicit heap. Anonymous heap growth can follow without blocking this startup increment. This partial runtime does not imply complete libc or toolchain support.

Tracking and rollout

Heap prerequisite: #8. Broader runtime scope: #1. Coordinate the consumer and producer in Posixd and Integration, with progress linked from Integration #65.

## Problem and motivation The process heap does not yet provide ordinary C startup. C programs need their authenticated launch arguments and environment, a real `main` call and defined normal or immediate exit. ## Proposed behavior and scope Add an explicit process-root startup companion using LCS1 and the shared C/Rust heap. Construct mutable counted `argv`, including `argc == 0`, and the exported environment. Provide `environ`, `getenv`, counted `atexit`, `exit` and `_Exit`. Preserve existing CLI admission rules. Keep command identity independent of `argv[0]`; do not invent a Linux initial stack or auxiliary data. ## Authority, security and reliability Retain launch, stream, thread and heap owners through the last reader and the genuine whole-process terminal fence. Environment strings grant no authority. Run callbacks outside registry locks, prevent replay after an interrupted drain and preserve uncertain terminal calls without retry. Process termination and resource reclamation remain distinct. ## Acceptance criteria - [ ] Admit ordinary C startup from the authenticated launch packet, with mutable arguments, exported environment and no fixed argument or registration count limit. - [ ] Call C `main` once, including zero arguments, and expose the selected environment without host lookup. - [ ] Implement ordered exit handlers, concurrent registration and distinct normal/immediate exit paths with retained failure custody. - [ ] Use the original process-group terminal backend and retain backing through sibling readers and shutdown. - [ ] Add the original-source producer, C consumer, regression controls, guest scenarios and component/manual contracts. - [ ] Demonstrate the native startup path; keep full sysroot, auxiliary data, FILE buffering and imported-tool acceptance separate. ## Alternatives and tradeoffs Reuse the existing launch ABI and explicit heap. Anonymous heap growth can follow without blocking this startup increment. This partial runtime does not imply complete libc or toolchain support. ## Tracking and rollout Heap prerequisite: [#8](https://git.erikinkinen.fi/erix/lib-cstd/issues/8). Broader runtime scope: [#1](https://git.erikinkinen.fi/erix/lib-cstd/issues/1). Coordinate the consumer and producer in Posixd and Integration, with progress linked from [Integration #65](https://git.erikinkinen.fi/erix/integration/issues/65).
erikinkinen changed title from Run ordinary C programs through explicit native startup to [FEATURE] Run ordinary C programs through explicit native startup 2026-10-26 10:59:44 +01:00
Author
Owner

The startup runtime and native C consumer are implemented in source. Mutable arguments and the exported environment use the shared process heap; normal exit drains handlers, while immediate exit uses the process-group terminal path. The producer, ordinary command catalog, dedicated image profiles and manual are wired together. Native acceptance remains open.

The startup runtime and native C consumer are implemented in source. Mutable arguments and the exported environment use the shared process heap; normal exit drains handlers, while immediate exit uses the process-group terminal path. The producer, ordinary command catalog, dedicated image profiles and manual are wired together. Native acceptance remains open.
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:34:40 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
erix/lib-cstd#9
No description provided.