From f927a01370f3d7d77717f64635c65cd9bc71a534 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 18 Nov 2007 15:19:02 -0600 Subject: [PATCH] unix: Added words to inspect status from wait/waitpid --- extra/unix/unix.factor | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/extra/unix/unix.factor b/extra/unix/unix.factor index 0854754dcb..10ff7a9efa 100644 --- a/extra/unix/unix.factor +++ b/extra/unix/unix.factor @@ -166,6 +166,10 @@ FUNCTION: time_t time ( time_t* t ) ; FUNCTION: int unlink ( char* path ) ; FUNCTION: int utimes ( char* path, timeval[2] times ) ; +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! wait and waitpid +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! Flags for waitpid : WNOHANG 1 ; @@ -176,7 +180,27 @@ FUNCTION: int utimes ( char* path, timeval[2] times ) ; : WCONTINUED 8 ; : WNOWAIT HEX: 1000000 ; +! Examining status + +: WTERMSIG ( status -- value ) HEX: 7f bitand ; + +: WIFEXITED ( status -- ? ) WTERMSIG zero? ; + +: WEXITSTATUS ( status -- value ) HEX: ff00 bitand -8 shift ; + +: WIFSIGNALED ( status -- ? ) HEX: 7f bitand 1+ -1 shift 0 > ; + +: WCOREFLAG ( -- value ) HEX: 80 ; + +: WCOREDUMP ( status -- ? ) WCOREFLAG bitand zero? not ; + +: WIFSTOPPED ( status -- ? ) HEX: ff bitand HEX: 7f = ; + +: WSTOPSIG ( status -- value ) WEXITSTATUS ; + FUNCTION: pid_t wait ( int* status ) ; FUNCTION: pid_t waitpid ( pid_t wpid, int* status, int options ) ; +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + FUNCTION: ssize_t write ( int fd, void* buf, size_t nbytes ) ;