Commit graph

7 commits

Author SHA1 Message Date
Nico Weber
ed0740d73c LibC: In posix_spawn(), use _exit instead of exit on child error
posix_spawn() tries to present semantics as if no fork() is happening
behind the scenes, so running arbitrary atexit handlers of the parent
in the child seems like the wrong thing to do.
2020-06-20 14:43:27 +02:00
Nico Weber
5208856688 LibC: Add addchdir() / addfchdir() to posix_spawn file actions
This isn't in posix yet, but it is implemented on some platforms
and it will be in a future version:
https://www.austingroupbugs.net/view.php?id=1208
2020-06-20 14:43:27 +02:00
Nico Weber
2ddca326be LibC: Add POSIX_SPAWN_SETSIGMASK
This isn't in posix yet, but it is implemented on some platforms
and it will be in a future version:
https://www.austingroupbugs.net/view.php?id=1044

It seems useful, so add it.
2020-06-20 14:43:27 +02:00
Nico Weber
39d1a43c45 LibC: Make sigprocmask error check more consistent with rest of this code 2020-06-20 14:43:27 +02:00
Nico Weber
7ffcc5a8b2 LibC: Implement file actions for posix_spawn 2020-06-19 22:11:38 +02:00
Nico Weber
e89a82a476 LibC: Add support for POSIX_SPAWN_RESETIDS
This is possible now that seteuid() / setegid() are implemented.
2020-06-19 20:34:59 +02:00
Nico Weber
4720635aab LibC: Add posix_spawn()!
All the file actions stuff is still missing for now,
as is POSIX_SPAWN_SETSCHEDULER (not sure what that's
supposed to do) and POSIX_SPAWN_RESETIDS.

Implemented in userspace for now. Once there are users,
it'll likely make sense to make this a syscall for
performance reasons.

A simple test program of the form

    extern char **environ;
    int main(int argc, char* argv[])
    {
        pid_t pid;
        char* args[] = { "ls", NULL };
        posix_spawnp(&pid, "ls", nullptr, nullptr, args, environ);
    }

works fine.
2020-06-17 18:49:06 +02:00