Skip to main content

Module stop

Module stop 

Source
Expand description

Stopping bynk dev from outside (#1955).

Without a handler, a SIGTERM or SIGINT sent to bynk dev alone (by a CI step, a test harness, an editor task) killed it on the spot, and its wranglers and their workerds ran on with their ports bound. A Ctrl-C in a terminal never showed it, because the terminal signals the whole foreground group, wranglers included.

install replaces the default action with one that only records the signal. bynk dev’s watch loop sees it on its next tick and stops its contexts the way it does when one of them exits: SIGTERM to each wrangler, then the sweep of what they leave behind (crate::sweep). The wranglers stay in bynk dev’s process group, because the sweep finds orphaned workerds by that group and a Ctrl-C must still reach them all.

The handler is one-shot (SA_RESETHAND): a second Ctrl-C while the contexts are stopping takes the default action and ends bynk dev at once.

Unix only. On Windows each wrangler’s job object holds its tree (#1762), and install does nothing.

Functions§

exit_byte
The exit byte for a session stopped by sig, as crate::shell::exit_status_byte maps a child’s signal death: SIGINT is a clean stop (it is what Ctrl-C sends), anything else 128 + sig, the shell convention.
install
Record SIGINT and SIGTERM instead of dying of them, for received to report. Children spawned afterwards are unaffected: exec resets a caught signal to its default action.
name
How to name sig in bynk dev’s stop notice.
received
The signal that asked bynk dev to stop, if one has arrived.