GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Exec in place instead of spawning and waiting in the CLI's wrapper processes · Issue #3106 · voidzero-dev/vite-plus

Exec in place instead of spawning and waiting in the CLI's wrapper processes #3106

New issue
Copy link
New issue
Copy link
Closed
Task
#3512
Closed
Exec in place instead of spawning and waiting in the CLI's wrapper processes#3106
Task
#3512
Copy link
Assignees
fengmk2

Description

@fengmk2
fengmk2
opened on Oct 18, 2026
Issue body actions

Follow-up to #2936, which made the project-local vpx bin replace itself with the script's Node.js through process.execve() on Unix instead of spawning it and waiting. The global CLI's shims already exec in place (exec_tool in crates/vp_global_cli/src/shim/exec.rs). Several other paths still spawn a child only to wait for it and pass its exit status on.

Why

  • One PID and real signals. The wrappers ignore SIGINT so that Ctrl+C reaches the child through the process group, and none of them forwards SIGTERM or SIGHUP. A tool that holds the PID of vp and sends it a signal (kill <pid>, a process manager, a test harness) stops the wrapper, or nothing, while the real process keeps running. SIGUSR1 opens a Node.js wrapper's inspector instead of the tool's, and kills the Rust vp wrapper while the tool keeps running.
  • Exact exit status. A child killed by a signal comes back as a plain exit code (exit_code_from_status, exit_status_from, process.exit(n) in bin.ts), so callers cannot tell SIGINT from exit 130.
  • Fewer idle processes. vp dev through the global CLI runs three processes: vp (Rust) waits for node dist/bin.js, which waits for the Vite Node.js process. An idle Node.js wrapper holds about 50 MB for as long as the dev server runs.

Startup time does not change, since each wrapper still starts before it execs.

Candidates

Strongest first. "After the child" is what the parent still does once the child exits, which an exec must move earlier or keep on the spawn path.

# Command Where After the child
1 global vpr → node <vite-plus>/dist/bin.js run … js_executor.rs run_js_entry → vp_command::execute_with_terminal_guard nothing (shim mode skips the upgrade notice)
2 global vpx pkg@version / -p / -c → package manager dlx vpx.rs → vp_pm_cli resolution/runner.rs run_command → vp_command::run_command nothing
3 vp env exec --node <v> [--npm <v>] <command> commands/env/exec.rs:235-252 the upgrade notice; the shim branch of the same command already execs
4 vp sync-versions with the packaged sidecar commands/sync_versions.rs:32-35 nothing
5 vp exec <command> for one package, without --report-summary binding/src/exec/workspace.rs:254 nothing in that case
6 vp dev, preview, build, test, pack, doc, lint (not --init) binding/src/cli/execution.rs:36-57 nothing; the --init and fmt paths filter output and stay as they are
7 package-manager passthrough in the local CLI (vp install, add, dlx, …, and the local vpx pkg@version) binding/src/cli/mod.rs → vp_pm_cli runner the toolchain hint after vp why only
8 global CLI delegation to JS (vp dev, build, test, lint, fmt, check, pack, run, …) cli.rs → commands/delegate.rs → js_executor.rs the cached upgrade notice (main.rs:597-599)
9 global package-manager passthrough (vp install, add, why, …) cli.rs → vp_pm_cli runner the vp why hint and the upgrade notice

Rows 2, 7, and 9 share vp_pm_cli's runner and vp_command::run_command, so an exec variant there covers them together. Rows 5–7 run inside the Node.js process of the local CLI. For row 8, the upgrade notice has to print before the exec, keep the spawn path when a notice is due, or be dropped as the shim branch already does.

Not candidates: npm install -g / uninstall -g (they link bins afterwards), vp fmt and vp check (they filter or capture output), vp run / vp cache (task graph, many children), multi-package and --parallel vp exec, the installer (it owns the temp directory with the binary), and every call that captures output.

Lessons from #2936

  • Blocking stdio. Node.js sets O_NONBLOCK on a pipe once it opens it as stdio, and process.execve() passes that on (process.execve() passes non-blocking stdio to the new program nodejs/node#66824), so the new program's writes fail with EAGAIN. bin.ts already restores blocking stdio; anything that execs from Node.js must do so first.
  • Signal dispositions. Node.js ignores SIGPIPE and SIGXFSZ, and an ignored signal stays ignored across exec. std's CommandExt::exec restores SIGPIPE but not SIGXFSZ. vpx-bin.ts restores both by adding and removing a listener.
  • A failed exec. process.execve() aborts Node.js on failure before 26.12 instead of throwing. vpx-bin.ts execs binaries through /bin/sh -c 'exec "$0" "$@"' for that reason. A Rust exec returns an error the caller can still report.
  • IPC. Exec closes an IPC channel, so a process started with one (NODE_CHANNEL_FD, process.send) keeps spawning.
  • Windows has no exec, so every path keeps its spawn there.
  • Rust side. tokio::process::Command::as_std_mut().exec() keeps the configured env, cwd, and pre_exec hooks (such as fix_stdio_streams), so the existing command builders can be reused.

Suggested order

  1. Add a Unix exec variant to vp_command next to run_command and execute_with_terminal_guard, and use it for rows 1–4.
  2. Use it for the local CLI's paths (rows 5–7), skipping exec when the process has an IPC channel and restoring SIGXFSZ.
  3. Decide the upgrade notice, then switch rows 8 and 9.

Separately, vp run does not forward SIGTERM to its tasks, which is out of scope here because it manages many children.

Activity

  1. fengmk2
    self-assigned this
    on Oct 18, 2026
  2. fengmk2
    added the
    Task
    issue type on Oct 18, 2026
  3. cayter commented on Nov 1, 2026

    @cayter
    cayter
    on Nov 1, 2026
    More actions

    Confirming candidate 6 for vp dev on vite-plus 1.4.0 (the latest), macOS, Node.js 26.13.0, in a project holding only vite-plus and an index.html:

    npm install [email protected]
    ./node_modules/.bin/vp dev --port 5599 --strictPort &
    # the Vite server's pid, and its parent: the vp wrapper
    server=$(lsof -tiTCP:5599 -sTCP:LISTEN); wrapper=$(ps -o ppid= -p "$server")
    kill -TERM "$wrapper"; sleep 3
    ps -p "$wrapper"                            # gone
    ps -p "$server"                             # still running, reparented to launchd
    curl -s -o /dev/null -w '%{http_code}\n' http://localhost:5599/   # 200

    The bundled Vite run directly (./node_modules/.bin/vite --port 5598) exits on the same SIGTERM. Ctrl+C works only because the terminal signals the whole process group, so an editor's stop button, a process manager or kill <pid> leaves the dev server (and anything it started) running and holding its port.

    Reacted by MK (fengmk2)
  4. fengmk2
    added 3 commits that reference this issue on Nov 23, 2026

    fix(cli): run project-local vp dev in the launcher process

    eef408b

    fix(cli): run project-local vp dev in the launcher process

    b055d64

    fix(cli): run project-local vp dev in the launcher process

    ef3dbb4
  5. fengmk2
    closed this as completedin be9b8fdon Nov 23, 2026
  6. jong-kyung
    added a commit that references this issue on Nov 23, 2026

    fix(cli): run project-local vp dev in the launcher process (voidzero-…

    This issue will close once commit be9b8fd is merged into the 'main' branch.
    be9b8fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @fengmk2
    fengmk2

Labels

No labels
No labels

Type

Task

Fields

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.