ludic/docs/language/process/process-poll.md
Orkuncakilkaya 43d5eb5b88 feat(launcher): Process.*, Http.save_to/received/expected, App.window_hide/show
Process.spawn/poll/kill/free - non-blocking child processes with no shell: posix_spawn on
macOS (process.ll), CreateProcessW with MSVC-quoted arguments and no console window on
Windows (process_win.ll), linked only when a program uses Process.*.

Http.save_to streams a response body into a file (NSURLSession with a run-time delegate
class on macOS, the WinHTTP read loop on Windows); Http.received / Http.expected report
progress while it is pending. Freeing a pending request cancels it and parks the slot
until the worker has finished.

App.window_hide / App.window_show take the game's window off the screen and back without
closing it; the run goes on while hidden. Docs, examples, tests and a changeset.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 13:32:23 +03:00

1.3 KiB

id name category kind tokens sig tip order ns member
process-poll Process.poll process namespace-method Process.poll Process.poll(handle) -> int -1 while running, else the exit code. 1 Process poll

Returns -1 while the child is still running and its exit code once it has ended; it never waits. The code is kept, so asking again gives the same answer until Process.free.

A child ended by a signal (macOS) answers 128 plus the signal number, as a shell reports it — 137 after Process.kill, on both platforms. On Windows the code is the child's DWORD exit code as an int, so a crash such as 0xC0000005 arrives as a negative number (test for != 0, not > 0); a code of 0xFFFFFFFF is reported as 255 so that -1 always means "still running". A handle that is not one answers 255.

program Demo {
  var game: int = -1
  handler Watch phase Update {
    if game >= 0 {
      let code = Process.poll(handle: game)
      if code >= 0 or code < -1 {
        if code != 0 { print("the game crashed") }
        Process.free(handle: game)
        game = -1
      }
    }
  }
}