Skip to content
FutureBlitz

    Install

    Import std.os.process_signals

    std.os.process_signals

    Process.OnInterrupt and Process.OnTerminate: handlers for the signals every OS has, which the program then gets instead of ending at once, until its code is done.

    std/os/process_signals.fb

    Extends

    Process extend

    Extend Process

    No doc comment.

    std/os/process_signals.fb, line 12

    • Public Static Method OnInterrupt(handler: Sendable Func()) static method #

      Runs handler each time the program is interrupted, by Ctrl+C, or on Windows Ctrl+Break too, which then doesn't end it. A handler runs on a thread of its own, one at a time, and once more for the signals that come while it runs. Once the program's code is done, its coroutines too, none runs, and the signal ends the program again; a call from then on, as from a thread that runs on, does nothing. A coroutine that waits for nothing but what a handler may give, a TaskSource's Task, waits for the signal.

    • Public Static Method OnTerminate(handler: Sendable Func()) static method #

      Runs handler each time something asks the program to end, by SIGTERM or SIGHUP, or on Windows by closing its console, as OnInterrupt runs its handler. Windows still ends the program a few seconds after its console closes, and has no SIGTERM to send it. On Linux and macOS, a signal the program started out ignoring, as nohup has it ignore SIGHUP, stays ignored, for OnInterrupt too, and no handler runs for it.

    Report an issue with this page or with FutureBlitz on GitHub.