summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/System.cpp
diff options
context:
space:
mode:
authorJunior Rantila <junior.rantila@gmail.com>2021-11-23 21:03:53 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-19 18:26:57 -0800
commit4178479ee52433020d58297636296f5fe41300ff (patch)
tree473828f8b19f76e85129c1d32e967c9b3db0859b /Userland/Libraries/LibCore/System.cpp
parent8eca395e4c9ffd3ef8bd6e2bd18e445666e1b63b (diff)
downloadserenity-4178479ee52433020d58297636296f5fe41300ff.zip
LibCore: Add wrapper for signal()
Diffstat (limited to 'Userland/Libraries/LibCore/System.cpp')
-rw-r--r--Userland/Libraries/LibCore/System.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp
index 4ebecf6a16..c572f56367 100644
--- a/Userland/Libraries/LibCore/System.cpp
+++ b/Userland/Libraries/LibCore/System.cpp
@@ -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 = {};