Skip to content

Launch /bin/sh as interactive login shell from init#918

Merged
dburkart merged 2 commits into
mainfrom
m900-interactive-sh
May 6, 2026
Merged

Launch /bin/sh as interactive login shell from init#918
dburkart merged 2 commits into
mainfrom
m900-interactive-sh

Conversation

@dburkart
Copy link
Copy Markdown
Owner

@dburkart dburkart commented May 6, 2026

Closes #900

Summary

  • After the existing hello fork+exec+wait smoke tests, init now launches /bin/sh as an interactive login shell with a proper argv (["sh"]) and environment (HOME=/, PATH=/bin:/usr/bin, TERM=vt100, PS1=vibix$ ).
  • If the shell exits (user types exit), init respawns it so the system stays usable.
  • The init: launching /bin/sh smoke marker (already in SMOKE_MARKERS) fires before each launch attempt.

Test plan

  • cargo xtask build passes
  • cargo fmt --all -- --check passes
  • cargo xtask smoke — smoke test environment has no KVM; CI will validate all markers including init: launching /bin/sh

After the existing hello smoke tests complete, init now launches
/bin/sh with a proper argv (["sh"]) and environment (HOME, PATH,
TERM, PS1). If the shell exits (user types `exit`), init respawns
it so the system stays usable.

Closes #900

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 33412e2d-3b61-44b0-b523-608b1d2ac3a2

📥 Commits

Reviewing files that changed from the base of the PR and between 94ba305 and 418ecd2.

📒 Files selected for processing (2)
  • base/init/src/main.rs
  • tests/fixtures/ext2_image.sha256

📝 Walkthrough

Walkthrough

The init binary's /bin/sh launcher is reworked from a one-shot smoke test into a respawn loop that continuously launches an interactive shell with proper environment variables (HOME, PATH, TERM, PS1) and diagnostic logging. The test fixture hash is updated to reflect the changed init binary.

Changes

Init Shell Respawn Loop

Layer / File(s) Summary
Diagnostic Constants
base/init/src/main.rs
New SH_RESPAWN_MSG diagnostic added to log shell respawn events.
Core Respawn Implementation
base/init/src/main.rs
Replaces single /bin/sh launch with a loop: fork creates child process, exec runs /bin/sh with minimal argv/envp (HOME, PATH, TERM, PS1 environment variables), parent calls wait4 to reap child, then logs respawn event and loops to relaunch shell on exit.
Test Fixture Update
tests/fixtures/ext2_image.sha256
SHA256 hash updated to reflect the modified init binary containing respawn logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • #895: This PR implements the core epic objective to run an interactive /bin/sh from init with respawning behavior and proper environment setup.
  • #900: This PR directly addresses the work items in this issue—fork+exec /bin/sh with minimal environment, respawn on exit, and diagnostic logging for init validation.

Possibly related PRs

  • dburkart/vibix#892: Implements the /bin/sh shell runtime and command execution entrypoints that receive input from the interactive session launched by this PR's init respawn loop.

Poem

🐰 Shell respawns in loops sublime,
Init forks and execs in time,
Each exit births a new shell run,
Interactive vibes, oh what fun!
HOME and PATH set just right,
Userspace shell shines so bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: launching /bin/sh as an interactive login shell from init, which is the primary objective of the PR.
Description check ✅ Passed The description is directly related to the changeset, detailing how init now launches /bin/sh with proper arguments, environment variables, and respawn behavior as outlined in issue #900.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #900: fork+exec /bin/sh without -c flag, provides minimal environment (HOME=/, PATH, TERM, PS1), handles stdin/stdout, implements respawn logic, and includes the smoke marker.
Out of Scope Changes check ✅ Passed All changes are scoped to the interactive /bin/sh launch requirement. The modifications to init/src/main.rs implement the respawn loop and environment setup, while the test fixture hash update reflects the expected system behavior changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch m900-interactive-sh

Comment @coderabbitai help to get the list of available commands and usage tips.

The init binary changed (added argv/envp to execve), which changes
the deterministic ext2 rootfs image hash.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dburkart dburkart merged commit 5d28a16 into main May 6, 2026
26 of 27 checks passed
@dburkart dburkart deleted the m900-interactive-sh branch May 6, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Launch /bin/sh as interactive login shell from init

2 participants