ludic/docs/language/process/process-spawn.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-spawn Process.spawn process namespace-method Process.spawn Process.spawn(path, args) -> int Start a program; never blocks. 0 Process spawn

Starts the program at path with the arguments in args (a []string; the child's argv[0] is path) and returns a handle >= 0 straight away, or -1 when the program could not be started — a missing file, a file that is not executable, or all 16 handles in use.

No shell is involved, so every argument reaches the child exactly as written: spaces, quotes and $ are not interpreted. The child inherits this process's environment and working directory. On Windows the arguments are joined into one command line quoted so the child's C runtime splits it back into the same list, the path and arguments cross as UTF-8 and are converted to UTF-16, and the child is started without a console window (a GUI program is unaffected; a console program runs hidden). Use an absolute path: there is no PATH search.

program Demo {
  entry {
    let h = Process.spawn("/bin/sh", ["-c", "exit 3"])
    print(h >= 0)
  }
}

See Process.poll for the exit code.