-USING: kernel alien.c-types alien.strings sequences math alien.syntax unix
-vectors kernel namespaces continuations threads assocs vectors
-io.backend.unix io.encodings.utf8 unix.utilities fry ;
+USING: kernel alien.c-types alien.data alien.strings sequences
+math alien.syntax unix namespaces continuations threads assocs
+io.backend.unix io.encodings.utf8 unix.types unix.utilities fry ;
IN: unix.process
! Low-level Unix process launching utilities. These are used
: fork-process ( -- pid ) [ fork ] unix-system-call ;
-FUNCTION: int execv ( char* path, char** argv ) ;
-FUNCTION: int execvp ( char* path, char** argv ) ;
-FUNCTION: int execve ( char* path, char** argv, char** envp ) ;
+FUNCTION: int execv ( c-string path, c-string* argv ) ;
+FUNCTION: int execvp ( c-string path, c-string* argv ) ;
+FUNCTION: int execve ( c-string path, c-string* argv, c-string* envp ) ;
: exec ( pathname argv -- int )
[ utf8 malloc-string ] [ utf8 strings>alien ] bi* execv ;
[ [ first ] [ ] bi ] dip exec-with-env ;
: with-fork ( child parent -- )
- [ [ fork-process dup zero? ] dip '[ drop @ ] ] dip
- if ; inline
+ [ fork-process ] 2dip if-zero ; inline
CONSTANT: SIGKILL 9
CONSTANT: SIGTERM 15
HEX: ff00 bitand -8 shift ; inline
: WIFSIGNALED ( status -- ? )
- HEX: 7f bitand 1+ -1 shift 0 > ; inline
+ HEX: 7f bitand 1 + -1 shift 0 > ; inline
: WCOREFLAG ( -- value )
HEX: 80 ; inline
FUNCTION: pid_t wait ( int* status ) ;
FUNCTION: pid_t waitpid ( pid_t wpid, int* status, int options ) ;
-
-: wait-for-pid ( pid -- status )
- 0 <int> [ 0 waitpid drop ] keep *int WEXITSTATUS ;