From ab5ebd0f5a26f289539910c7cb9585ce885c22c6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 5 Apr 2008 23:26:33 -0500 Subject: [PATCH 1/2] Fix buffering issue --- extra/io/unix/launcher/launcher.factor | 2 +- extra/unix/unix.factor | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/io/unix/launcher/launcher.factor b/extra/io/unix/launcher/launcher.factor index ef0107beb1..c104587c77 100755 --- a/extra/io/unix/launcher/launcher.factor +++ b/extra/io/unix/launcher/launcher.factor @@ -77,7 +77,7 @@ USE: unix get-arguments exec-args-with-path (io-error) - ] [ 255 exit ] recover ; + ] [ 255 _exit "Exit failed" throw ] recover ; M: unix current-process-handle ( -- handle ) getpid ; diff --git a/extra/unix/unix.factor b/extra/unix/unix.factor index e911a5c039..3d4ce3cd48 100755 --- a/extra/unix/unix.factor +++ b/extra/unix/unix.factor @@ -43,6 +43,7 @@ FUNCTION: int dup2 ( int oldd, int newd ) ; 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 _exit ( int status ) ; FUNCTION: int fchdir ( int fd ) ; FUNCTION: int fchown ( int fd, uid_t owner, gid_t group ) ; FUNCTION: int fcntl ( int fd, int cmd, int arg ) ; From d2468ad9ed38e6aca0fc80691a5f662208de4a7f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 5 Apr 2008 23:31:41 -0500 Subject: [PATCH 2/2] Add launcher error codes --- extra/io/unix/launcher/launcher.factor | 22 +++++++++++----------- extra/unix/unix.factor | 4 +++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/extra/io/unix/launcher/launcher.factor b/extra/io/unix/launcher/launcher.factor index c104587c77..2736764665 100755 --- a/extra/io/unix/launcher/launcher.factor +++ b/extra/io/unix/launcher/launcher.factor @@ -66,18 +66,18 @@ USE: unix ?closed write-flags 2 redirect ] if ; -: spawn-process ( process -- * ) - [ - setup-priority - setup-redirection - current-directory get (normalize-path) cd - dup pass-environment? [ - dup get-environment set-os-envs - ] when +: setup-environment ( process -- process ) + dup pass-environment? [ + dup get-environment set-os-envs + ] when ; - get-arguments exec-args-with-path - (io-error) - ] [ 255 _exit "Exit failed" throw ] recover ; +: spawn-process ( process -- * ) + [ setup-priority ] [ 250 _exit ] recover + [ setup-redirection ] [ 251 _exit ] recover + [ current-directory get (normalize-path) cd ] [ 252 _exit ] recover + [ setup-environment ] [ 253 _exit ] recover + [ get-arguments exec-args-with-path ] [ 254 _exit ] recover + 255 _exit ; M: unix current-process-handle ( -- handle ) getpid ; diff --git a/extra/unix/unix.factor b/extra/unix/unix.factor index 3d4ce3cd48..9005cd2b2a 100755 --- a/extra/unix/unix.factor +++ b/extra/unix/unix.factor @@ -43,7 +43,9 @@ FUNCTION: int dup2 ( int oldd, int newd ) ; 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 _exit ( int status ) ; +: _exit ( status -- * ) + #! We throw to give this a terminating stack effect. + "int" f "_exit" { "int" } alien-invoke "Exit failed" throw ; FUNCTION: int fchdir ( int fd ) ; FUNCTION: int fchown ( int fd, uid_t owner, gid_t group ) ; FUNCTION: int fcntl ( int fd, int cmd, int arg ) ;