added deprecation note, and link to Uroborus
[urforth.git] / samples / exec-sample.f
blob40e0bc324c40262dd14cdfb2bbe56b4ba7be3069
1 use-libs: exec os-errno
3 : (errno?) ( errno false // ... true -- ... )
4 ifnot
5 endcr ." CANNOT EXEC; ERROR: " os:errno-name type cr
6 1 n-bye
7 endif
10 : test-exec ( -- )
11 ;; env
12 os:strarray-envp (errno?)
13 os:strarray-finalize dup >r os:strarray->array
14 \ r@ os:strarray-dump .stack bye
15 ;; args
16 os:strarray-init (errno?)
17 " /usr/bin/ls" os:strarray-push (errno?)
18 " -la" os:strarray-push (errno?)
19 os:strarray-finalize dup >r os:strarray->array
20 \ r@ os:strarray-dump .stack bye
21 r@ os:strarray-first
22 \ dup zcount type cr
23 os:exec
24 r> os:strarray-free r> os:strarray-free
25 ifnot
26 endcr ." CANNOT EXEC; ERROR: " os:errno-name type cr
27 1 n-bye
28 endif
29 \ .stack
30 ." PID: " dup . cr
31 ( os:WEXITED) 0 os:wait ifnot
32 endcr ." CANNOT WAIT; ERROR: " os:errno-name type cr
33 1 n-bye
34 endif
35 ." WAIT PID: " . cr
36 ." WAIT CODE: 0x" dup .hex8 cr
37 ." WTERMSIG: " dup os:WTERMSIG . cr
38 ." WEXITSTATUS: " dup os:WEXITSTATUS . cr
39 drop
43 test-exec
44 .stack bye