1 | Index: third-party/chicken/posixwin.scm |
---|
2 | =================================================================== |
---|
3 | --- third-party/chicken/posixwin.scm (revision 145203) |
---|
4 | +++ third-party/chicken/posixwin.scm (revision 145204) |
---|
5 | @@ -92,6 +92,7 @@ |
---|
6 | static C_TLS HANDLE C_save0, C_save1; /* saved I/O handles */ |
---|
7 | static C_TLS char C_rdbuf; /* one-char buffer for read */ |
---|
8 | static C_TLS int C_exstatus; |
---|
9 | +static C_TLS HANDLE C_pid; |
---|
10 | |
---|
11 | /* platform information; initialized for cached testing */ |
---|
12 | static C_TLS char C_hostname[256] = ""; |
---|
13 | @@ -318,15 +319,22 @@ |
---|
14 | static int C_fcall |
---|
15 | process_wait(C_word h, C_word t) |
---|
16 | { |
---|
17 | - if (WaitForSingleObject((HANDLE)h, (t ? 0 : INFINITE)) == WAIT_OBJECT_0) |
---|
18 | + DWORD wait_result = WaitForSingleObject((HANDLE)h, (t ? 0 : INFINITE)); |
---|
19 | + DWORD ret; |
---|
20 | + switch (wait_result) |
---|
21 | { |
---|
22 | - DWORD ret; |
---|
23 | - if (GetExitCodeProcess((HANDLE)h, &ret)) |
---|
24 | - { |
---|
25 | - CloseHandle((HANDLE)h); |
---|
26 | - C_exstatus = ret; |
---|
27 | - return 1; |
---|
28 | - } |
---|
29 | + case WAIT_OBJECT_0: |
---|
30 | + if (GetExitCodeProcess((HANDLE)h, &ret)) |
---|
31 | + { |
---|
32 | + CloseHandle((HANDLE)h); |
---|
33 | + C_exstatus = ret; |
---|
34 | + C_pid = (HANDLE)h; |
---|
35 | + return 1; |
---|
36 | + } |
---|
37 | + break; |
---|
38 | + case WAIT_TIMEOUT: |
---|
39 | + C_pid = 0; |
---|
40 | + return 1; |
---|
41 | } |
---|
42 | return set_last_errno(); |
---|
43 | } |
---|
44 | @@ -1267,10 +1275,11 @@ |
---|
45 | (%process 'process* #t cmd args env exactf) )) ) |
---|
46 | |
---|
47 | (define-foreign-variable _exstatus int "C_exstatus") |
---|
48 | +(define-foreign-variable _pid int "C_pid") |
---|
49 | |
---|
50 | (define (##sys#process-wait pid nohang) |
---|
51 | (if (##core#inline "C_process_wait" pid nohang) |
---|
52 | - (values pid #t _exstatus) |
---|
53 | + (values _pid #t _exstatus) |
---|
54 | (values -1 #f #f) ) ) |
---|
55 | |
---|
56 | (define (sleep s) |
---|