LibCore: Add syscall wrapper for dup()
This commit is contained in:
parent
cb9cac4e40
commit
83056efc1a
Notes:
sideshowbarker
2024-07-18 00:33:33 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/83056efc1af
2 changed files with 9 additions and 0 deletions
|
@ -196,6 +196,14 @@ ErrorOr<void> kill(pid_t pid, int signal)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<int> dup(int source_fd)
|
||||
{
|
||||
int fd = ::dup(source_fd);
|
||||
if (fd < 0)
|
||||
return Error::from_syscall("dup"sv, -errno);
|
||||
return fd;
|
||||
}
|
||||
|
||||
ErrorOr<int> dup2(int source_fd, int destination_fd)
|
||||
{
|
||||
int fd = ::dup2(source_fd, destination_fd);
|
||||
|
|
|
@ -32,6 +32,7 @@ ErrorOr<struct stat> stat(StringView path);
|
|||
ErrorOr<ssize_t> read(int fd, Bytes buffer);
|
||||
ErrorOr<ssize_t> write(int fd, ReadonlyBytes buffer);
|
||||
ErrorOr<void> kill(pid_t, int signal);
|
||||
ErrorOr<int> dup(int source_fd);
|
||||
ErrorOr<int> dup2(int source_fd, int destination_fd);
|
||||
ErrorOr<String> ptsname(int fd);
|
||||
ErrorOr<String> gethostname();
|
||||
|
|
Loading…
Add table
Reference in a new issue