From 3433adefbe9e8397e5a0f84b4275b50d4da100f0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 4 Feb 2008 19:58:07 -0600 Subject: [PATCH 1/2] Fix wait-for-pid --- extra/unix/process/process.factor | 2 +- extra/unix/unix.factor | 36 +++++++++++++++++++------------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/extra/unix/process/process.factor b/extra/unix/process/process.factor index fb4271ea23..8b7144b979 100755 --- a/extra/unix/process/process.factor +++ b/extra/unix/process/process.factor @@ -32,4 +32,4 @@ IN: unix.process fork dup zero? -roll swap curry if ; inline : wait-for-pid ( pid -- status ) - 0 [ 0 waitpid drop ] keep *int ; \ No newline at end of file + 0 [ 0 waitpid drop ] keep *int WEXITSTATUS ; \ No newline at end of file diff --git a/extra/unix/unix.factor b/extra/unix/unix.factor index 7c3467b052..750a4b5044 100755 --- a/extra/unix/unix.factor +++ b/extra/unix/unix.factor @@ -177,31 +177,39 @@ FUNCTION: int kill ( pid_t pid, int sig ) ; ! Flags for waitpid -: WNOHANG 1 ; -: WUNTRACED 2 ; +: WNOHANG 1 ; inline +: WUNTRACED 2 ; inline -: WSTOPPED 2 ; -: WEXITED 4 ; -: WCONTINUED 8 ; -: WNOWAIT HEX: 1000000 ; +: WSTOPPED 2 ; inline +: WEXITED 4 ; inline +: WCONTINUED 8 ; inline +: WNOWAIT HEX: 1000000 ; inline ! Examining status -: WTERMSIG ( status -- value ) HEX: 7f bitand ; +: WTERMSIG ( status -- value ) + HEX: 7f bitand ; inline -: WIFEXITED ( status -- ? ) WTERMSIG zero? ; +: WIFEXITED ( status -- ? ) + WTERMSIG zero? ; inline -: WEXITSTATUS ( status -- value ) HEX: ff00 bitand -8 shift ; +: WEXITSTATUS ( status -- value ) + HEX: ff00 bitand -8 shift ; inline -: WIFSIGNALED ( status -- ? ) HEX: 7f bitand 1+ -1 shift 0 > ; +: WIFSIGNALED ( status -- ? ) + HEX: 7f bitand 1+ -1 shift 0 > ; inline -: WCOREFLAG ( -- value ) HEX: 80 ; +: WCOREFLAG ( -- value ) + HEX: 80 ; inline -: WCOREDUMP ( status -- ? ) WCOREFLAG bitand zero? not ; +: WCOREDUMP ( status -- ? ) + WCOREFLAG bitand zero? not ; inline -: WIFSTOPPED ( status -- ? ) HEX: ff bitand HEX: 7f = ; +: WIFSTOPPED ( status -- ? ) + HEX: ff bitand HEX: 7f = ; inline -: WSTOPSIG ( status -- value ) WEXITSTATUS ; +: WSTOPSIG ( status -- value ) + WEXITSTATUS ; inline FUNCTION: pid_t wait ( int* status ) ; FUNCTION: pid_t waitpid ( pid_t wpid, int* status, int options ) ; From f1989fc8c6142671cc27d5f0d14041b05a104d50 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 4 Feb 2008 20:10:00 -0600 Subject: [PATCH 2/2] Fix io.launcher again --- extra/io/unix/launcher/launcher.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/io/unix/launcher/launcher.factor b/extra/io/unix/launcher/launcher.factor index b44ac80159..93278e2b1a 100755 --- a/extra/io/unix/launcher/launcher.factor +++ b/extra/io/unix/launcher/launcher.factor @@ -111,7 +111,7 @@ M: unix-io process-stream* 2drop t ] [ find-process dup [ - >r *uint r> notify-exit f + >r *int WEXITSTATUS r> notify-exit f ] [ 2drop f ] if