mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibCore: Add wrapper for signal()
This commit is contained in:
parent
8eca395e4c
commit
4178479ee5
2 changed files with 18 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibSystem/syscall.h>
|
#include <LibSystem/syscall.h>
|
||||||
|
#include <cstring>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
@ -115,6 +116,18 @@ ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigac
|
||||||
return {};
|
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)
|
ErrorOr<struct stat> fstat(int fd)
|
||||||
{
|
{
|
||||||
struct stat st = {};
|
struct stat st = {};
|
||||||
|
|
|
@ -31,6 +31,11 @@ ErrorOr<void> mount(int source_fd, StringView target, StringView fs_type, int fl
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);
|
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<struct stat> fstat(int fd);
|
||||||
ErrorOr<int> fcntl(int fd, int command, ...);
|
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 = {});
|
ErrorOr<void*> mmap(void* address, size_t, int protection, int flags, int fd, off_t, size_t alignment = 0, StringView name = {});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue