LibCore: Add wrapper for signal()
This commit is contained in:
parent
8eca395e4c
commit
4178479ee5
Notes:
sideshowbarker
2024-07-17 22:34:39 +09:00
Author: https://github.com/juniorrantila Commit: https://github.com/SerenityOS/serenity/commit/4178479ee52 Pull-request: https://github.com/SerenityOS/serenity/pull/11047 Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 18 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibSystem/syscall.h>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
@ -115,6 +116,18 @@ ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigac
|
|||
return {};
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
ErrorOr<sig_t> signal(int signal, sig_t handler)
|
||||
#else
|
||||
ErrorOr<sighandler_t> signal(int signal, sighandler_t handler)
|
||||
#endif
|
||||
{
|
||||
auto old_handler = ::signal(signal, handler);
|
||||
if (old_handler == SIG_ERR)
|
||||
return Error::from_syscall("signal"sv, -errno);
|
||||
return old_handler;
|
||||
}
|
||||
|
||||
ErrorOr<struct stat> fstat(int fd)
|
||||
{
|
||||
struct stat st = {};
|
||||
|
|
|
@ -31,6 +31,11 @@ ErrorOr<void> mount(int source_fd, StringView target, StringView fs_type, int fl
|
|||
#endif
|
||||
|
||||
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);
|
||||
#ifdef __APPLE__
|
||||
ErrorOr<sig_t> signal(int signal, sig_t handler);
|
||||
#else
|
||||
ErrorOr<sighandler_t> signal(int signal, sighandler_t handler);
|
||||
#endif
|
||||
ErrorOr<struct stat> fstat(int fd);
|
||||
ErrorOr<int> fcntl(int fd, int command, ...);
|
||||
ErrorOr<void*> mmap(void* address, size_t, int protection, int flags, int fd, off_t, size_t alignment = 0, StringView name = {});
|
||||
|
|
Loading…
Add table
Reference in a new issue