aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/unistd.ccm
diff options
context:
space:
mode:
Diffstat (limited to 'nihil.posix/unistd.ccm')
-rw-r--r--nihil.posix/unistd.ccm23
1 files changed, 23 insertions, 0 deletions
diff --git a/nihil.posix/unistd.ccm b/nihil.posix/unistd.ccm
new file mode 100644
index 0000000..14c19ee
--- /dev/null
+++ b/nihil.posix/unistd.ccm
@@ -0,0 +1,23 @@
+// This source code is released into the public domain.
+module;
+
+#include <unistd.h>
+
+export module nihil.posix:unistd;
+
+import nihil.std;
+import nihil.error;
+
+// Symbols from unistd.h that might be useful.
+
+namespace nihil {
+
+export [[nodiscard]] auto fork() -> std::expected<::pid_t, error>
+{
+ auto const pid = ::fork();
+ if (pid == -1)
+ return std::unexpected(error(sys_error()));
+ return pid;
+}
+
+};