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>
This commit is contained in:
parent
c1db0d71ed
commit
43d5eb5b88
31 changed files with 89274 additions and 86727 deletions
32
docs/language/process/process-poll.md
Normal file
32
docs/language/process/process-poll.md
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
id: process-poll
|
||||
name: Process.poll
|
||||
category: process
|
||||
kind: namespace-method
|
||||
tokens: Process.poll
|
||||
sig: Process.poll(handle) -> int
|
||||
tip: -1 while running, else the exit code.
|
||||
order: 1
|
||||
ns: Process
|
||||
member: poll
|
||||
---
|
||||
|
||||
Returns <code>-1</code> 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 <a href="process-free.html"><code>Process.free</code></a>.
|
||||
|
||||
A child ended by a signal (macOS) answers <code>128</code> plus the signal number, as a shell reports it — <code>137</code> after <a href="process-kill.html"><code>Process.kill</code></a>, on both platforms. On Windows the code is the child's DWORD exit code as an <code>int</code>, so a crash such as <code>0xC0000005</code> arrives as a negative number (test for <code>!= 0</code>, not <code>> 0</code>); a code of <code>0xFFFFFFFF</code> is reported as <code>255</code> so that <code>-1</code> always means "still running". A handle that is not one answers <code>255</code>.
|
||||
|
||||
```ludic
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue