diff --git a/extra/io/unix/launcher/launcher.factor b/extra/io/unix/launcher/launcher.factor index ef0107beb1..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 ] 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 e911a5c039..9005cd2b2a 100755 --- a/extra/unix/unix.factor +++ b/extra/unix/unix.factor @@ -43,6 +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 ) ; +: _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 ) ;