mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +00:00
LibCore: Add posix_spawn() wrapper to Core::System
This commit is contained in:
parent
5a24accfa7
commit
0295d79339
2 changed files with 15 additions and 4 deletions
|
@ -661,14 +661,24 @@ ErrorOr<void> clock_settime(clockid_t clock_id, struct timespec* ts)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<pid_t> posix_spawnp(StringView const path, posix_spawn_file_actions_t* const file_actions, posix_spawnattr_t* const attr, char* const arguments[], char* const envp[])
|
static ALWAYS_INLINE ErrorOr<pid_t> posix_spawn_wrapper(StringView path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const arguments[], char* const envp[], StringView function_name, decltype(::posix_spawn) spawn_function)
|
||||||
{
|
{
|
||||||
pid_t child_pid;
|
pid_t child_pid;
|
||||||
if ((errno = ::posix_spawnp(&child_pid, path.to_string().characters(), file_actions, attr, arguments, envp)))
|
if ((errno = spawn_function(&child_pid, path.to_string().characters(), file_actions, attr, arguments, envp)))
|
||||||
return Error::from_syscall("posix_spawnp"sv, -errno);
|
return Error::from_syscall(function_name, -errno);
|
||||||
return child_pid;
|
return child_pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<pid_t> posix_spawn(StringView path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const arguments[], char* const envp[])
|
||||||
|
{
|
||||||
|
return posix_spawn_wrapper(path, file_actions, attr, arguments, envp, "posix_spawn"sv, ::posix_spawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOr<pid_t> posix_spawnp(StringView path, posix_spawn_file_actions_t* const file_actions, posix_spawnattr_t* const attr, char* const arguments[], char* const envp[])
|
||||||
|
{
|
||||||
|
return posix_spawn_wrapper(path, file_actions, attr, arguments, envp, "posix_spawnp"sv, ::posix_spawnp);
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<off_t> lseek(int fd, off_t offset, int whence)
|
ErrorOr<off_t> lseek(int fd, off_t offset, int whence)
|
||||||
{
|
{
|
||||||
off_t rc = ::lseek(fd, offset, whence);
|
off_t rc = ::lseek(fd, offset, whence);
|
||||||
|
|
|
@ -97,7 +97,8 @@ ErrorOr<Optional<struct group>> getgrnam(StringView name);
|
||||||
ErrorOr<Optional<struct passwd>> getpwuid(uid_t);
|
ErrorOr<Optional<struct passwd>> getpwuid(uid_t);
|
||||||
ErrorOr<Optional<struct group>> getgrgid(gid_t);
|
ErrorOr<Optional<struct group>> getgrgid(gid_t);
|
||||||
ErrorOr<void> clock_settime(clockid_t clock_id, struct timespec* ts);
|
ErrorOr<void> clock_settime(clockid_t clock_id, struct timespec* ts);
|
||||||
ErrorOr<pid_t> posix_spawnp(StringView const path, posix_spawn_file_actions_t* const file_actions, posix_spawnattr_t* const attr, char* const arguments[], char* const envp[]);
|
ErrorOr<pid_t> posix_spawn(StringView path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const arguments[], char* const envp[]);
|
||||||
|
ErrorOr<pid_t> posix_spawnp(StringView path, posix_spawn_file_actions_t* const file_actions, posix_spawnattr_t* const attr, char* const arguments[], char* const envp[]);
|
||||||
ErrorOr<off_t> lseek(int fd, off_t, int whence);
|
ErrorOr<off_t> lseek(int fd, off_t, int whence);
|
||||||
|
|
||||||
struct WaitPidResult {
|
struct WaitPidResult {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue