unix.process: Add posix_spawn stub.

I couldn't get this to work in all cases to replace spawn-process yet.

```
! works
{ "/bin/ls" "-al" } posix-spawn-args-with-path

! Broken on Linux64 for some reason
{
    "/usr/bin/code"
    "-g"
    "-r"
    "/home/erg/factor-master/basis/io/launcher/launcher.factor"
} posix-spawn-args-with-path
```
flac
Doug Coleman 2020-03-15 17:18:37 -05:00 committed by Steve Ayerhart
parent d8ec9dca97
commit 67aa7b8b11
No known key found for this signature in database
GPG Key ID: 5BFD39C5359E967D
2 changed files with 30 additions and 2 deletions

View File

@ -1,5 +1,6 @@
USING: alien.c-types alien.data alien.syntax io.encodings.utf8
kernel libc math sequences unix unix.types unix.utilities ;
USING: alien.c-types alien.data alien.syntax classes.struct
generalizations io.encodings.utf8 kernel libc math sequences
unix unix.types unix.utilities ;
IN: unix.process
! Low-level Unix process launching utilities. These are used
@ -14,6 +15,30 @@ 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 )
TYPEDEF: void posix_spawn_file_actions_t
TYPEDEF: void posix_spawnattr_t
FUNCTION: int posix_spawn ( pid_t *pid, c-string path,
posix_spawn_file_actions_t *file_actions,
posix_spawnattr_t *attrp,
c-string* argv, c-string* envp )
FUNCTION: int posix_spawnp ( pid_t *pid, c-string file,
posix_spawn_file_actions_t *file_actions,
posix_spawnattr_t *attrp,
c-string* argv, c-string* envp )
: posix-spawn ( path posix_spawn_file_actions_t* posix_spawnattr_t* argv envp -- pid_t )
[ [ 0 pid_t <ref> ] dip utf8 malloc-string ] 4dip
[ utf8 strings>alien ] bi@
[
posix_spawnp dup 0 = [ drop ] [ throw-errno ] if
] 6 nkeep 5drop pid_t deref ;
: posix-spawn-args-with-path ( seq -- int )
[ first f f ] keep f posix-spawn ;
: exec ( pathname argv -- int )
[ utf8 malloc-string ] [ utf8 strings>alien ] bi* execv ;

View File

@ -6,6 +6,8 @@ TYPEDEF: ulong __ulongword_type
TYPEDEF: long __sword_type
TYPEDEF: ulong __uword_type
TYPEDEF: long __slongword_type
TYPEDEF: uint __u32
TYPEDEF: ulonglong __u64
TYPEDEF: uint __u32_type
TYPEDEF: int __s32_type
@ -22,6 +24,7 @@ TYPEDEF: __slongword_type blksize_t
TYPEDEF: __slongword_type blkcnt_t
TYPEDEF: __sword_type ssize_t
TYPEDEF: __s32_type pid_t
TYPEDEF: ulong sigset_t
TYPEDEF: __slongword_type time_t
TYPEDEF: __slongword_type __time_t