summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-12-16 20:28:54 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-16 22:48:17 +0100
commit2637a641301fa27df8f101f4b587e87390909ee3 (patch)
treef4fe797d74b779c17b46cdd23620781d091441f9 /Userland
parent01c2756e9a6796d56372e2776854c6378b00c0eb (diff)
downloadserenity-2637a641301fa27df8f101f4b587e87390909ee3.zip
LibCore: Add syscall wrapper for fork()
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCore/System.cpp8
-rw-r--r--Userland/Libraries/LibCore/System.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp
index c86c22f083..d4807c8b17 100644
--- a/Userland/Libraries/LibCore/System.cpp
+++ b/Userland/Libraries/LibCore/System.cpp
@@ -480,4 +480,12 @@ ErrorOr<void> mkdir(StringView path, mode_t mode)
#endif
}
+ErrorOr<pid_t> fork()
+{
+ pid_t pid = ::fork();
+ if (pid < 0)
+ return Error::from_syscall("fork"sv, -errno);
+ return pid;
+}
+
}
diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h
index 7032b5553e..c4b668739a 100644
--- a/Userland/Libraries/LibCore/System.h
+++ b/Userland/Libraries/LibCore/System.h
@@ -64,5 +64,6 @@ ErrorOr<void> setegid(gid_t);
ErrorOr<bool> isatty(int fd);
ErrorOr<void> symlink(StringView target, StringView link_path);
ErrorOr<void> mkdir(StringView path, mode_t);
+ErrorOr<pid_t> fork();
}