summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-12-21 15:59:15 -0800
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-21 18:16:48 -0800
commit890fba95f78a0e01ba8902f3339322c7e89816ca (patch)
treec6cb99532086b04ea8b7f1ad45d1112368ed374e /Userland
parent6fe71970f524f5bb845b2e58cf84038f0cc4703d (diff)
downloadserenity-890fba95f78a0e01ba8902f3339322c7e89816ca.zip
LibC: Add POSIX spec comments for posix_spawn APIs
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibC/spawn.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/spawn.cpp b/Userland/Libraries/LibC/spawn.cpp
index 297c5d4d9c..96b7fe857a 100644
--- a/Userland/Libraries/LibC/spawn.cpp
+++ b/Userland/Libraries/LibC/spawn.cpp
@@ -99,6 +99,7 @@ extern "C" {
_exit(127);
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html
int posix_spawn(pid_t* out_pid, const char* path, const posix_spawn_file_actions_t* file_actions, const posix_spawnattr_t* attr, char* const argv[], char* const envp[])
{
pid_t child_pid = fork();
@@ -113,6 +114,7 @@ int posix_spawn(pid_t* out_pid, const char* path, const posix_spawn_file_actions
posix_spawn_child(path, file_actions, attr, argv, envp, execve);
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnp.html
int posix_spawnp(pid_t* out_pid, const char* path, const posix_spawn_file_actions_t* file_actions, const posix_spawnattr_t* attr, char* const argv[], char* const envp[])
{
pid_t child_pid = fork();
@@ -127,6 +129,7 @@ int posix_spawnp(pid_t* out_pid, const char* path, const posix_spawn_file_action
posix_spawn_child(path, file_actions, attr, argv, envp, execvpe);
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addchdir.html
int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t* actions, const char* path)
{
actions->state->actions.append([path]() { return chdir(path); });
@@ -139,18 +142,21 @@ int posix_spawn_file_actions_addfchdir(posix_spawn_file_actions_t* actions, int
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addclose.html
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t* actions, int fd)
{
actions->state->actions.append([fd]() { return close(fd); });
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_adddup2.html
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t* actions, int old_fd, int new_fd)
{
actions->state->actions.append([old_fd, new_fd]() { return dup2(old_fd, new_fd); });
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addopen.html
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* actions, int want_fd, const char* path, int flags, mode_t mode)
{
actions->state->actions.append([want_fd, path, flags, mode]() {
@@ -164,59 +170,69 @@ int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* actions, int wa
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_destroy.html
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t* actions)
{
delete actions->state;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_init.html
int posix_spawn_file_actions_init(posix_spawn_file_actions_t* actions)
{
actions->state = new posix_spawn_file_actions_state;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_destroy.html
int posix_spawnattr_destroy(posix_spawnattr_t*)
{
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getflags.html
int posix_spawnattr_getflags(const posix_spawnattr_t* attr, short* out_flags)
{
*out_flags = attr->flags;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getpgroup.html
int posix_spawnattr_getpgroup(const posix_spawnattr_t* attr, pid_t* out_pgroup)
{
*out_pgroup = attr->pgroup;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getschedparam.html
int posix_spawnattr_getschedparam(const posix_spawnattr_t* attr, struct sched_param* out_schedparam)
{
*out_schedparam = attr->schedparam;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getschedpolicy.html
int posix_spawnattr_getschedpolicy(const posix_spawnattr_t* attr, int* out_schedpolicty)
{
*out_schedpolicty = attr->schedpolicy;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getsigdefault.html
int posix_spawnattr_getsigdefault(const posix_spawnattr_t* attr, sigset_t* out_sigdefault)
{
*out_sigdefault = attr->sigdefault;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_getsigmask.html
int posix_spawnattr_getsigmask(const posix_spawnattr_t* attr, sigset_t* out_sigmask)
{
*out_sigmask = attr->sigmask;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_init.html
int posix_spawnattr_init(posix_spawnattr_t* attr)
{
attr->flags = 0;
@@ -228,6 +244,7 @@ int posix_spawnattr_init(posix_spawnattr_t* attr)
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setflags.html
int posix_spawnattr_setflags(posix_spawnattr_t* attr, short flags)
{
if (flags & ~(POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSID))
@@ -237,30 +254,35 @@ int posix_spawnattr_setflags(posix_spawnattr_t* attr, short flags)
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setpgroup.html
int posix_spawnattr_setpgroup(posix_spawnattr_t* attr, pid_t pgroup)
{
attr->pgroup = pgroup;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setschedparam.html
int posix_spawnattr_setschedparam(posix_spawnattr_t* attr, const struct sched_param* schedparam)
{
attr->schedparam = *schedparam;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setschedpolicy.html
int posix_spawnattr_setschedpolicy(posix_spawnattr_t* attr, int schedpolicy)
{
attr->schedpolicy = schedpolicy;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setsigdefault.html
int posix_spawnattr_setsigdefault(posix_spawnattr_t* attr, const sigset_t* sigdefault)
{
attr->sigdefault = *sigdefault;
return 0;
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_setsigmask.html
int posix_spawnattr_setsigmask(posix_spawnattr_t* attr, const sigset_t* sigmask)
{
attr->sigmask = *sigmask;