1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibCore: Make Core::System::pipe2() available on Lagom

Note that this drops the flags on the floor if not on linux or serenity.
This commit is contained in:
Ali Mohammad Pur 2021-12-21 06:16:46 +03:30 committed by Ali Mohammad Pur
parent b303b8cf4e
commit ee46cee31f
2 changed files with 14 additions and 9 deletions

View file

@ -45,14 +45,6 @@ ErrorOr<void> unveil(StringView path, StringView permissions)
HANDLE_SYSCALL_RETURN_VALUE("unveil"sv, rc, {});
}
ErrorOr<Array<int, 2>> pipe2(int flags)
{
Array<int, 2> fds;
if (::pipe2(fds.data(), flags) < 0)
return Error::from_syscall("pipe2"sv, -errno);
return fds;
}
ErrorOr<void> sendfd(int sockfd, int fd)
{
if (::sendfd(sockfd, fd) < 0)
@ -709,4 +701,17 @@ ErrorOr<void> socketpair(int domain, int type, int protocol, int sv[2])
return {};
}
ErrorOr<Array<int, 2>> pipe2([[maybe_unused]] int flags)
{
Array<int, 2> fds;
#if defined(__unix__)
if (::pipe2(fds.data(), flags) < 0)
return Error::from_syscall("pipe2"sv, -errno);
#else
if (::pipe(fds.data()) < 0)
return Error::from_syscall("pipe2"sv, -errno);
#endif
return fds;
}
}