summaryrefslogtreecommitdiff
path: root/libc/src/unistd/linux/setsid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/unistd/linux/setsid.cpp')
-rw-r--r--libc/src/unistd/linux/setsid.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/libc/src/unistd/linux/setsid.cpp b/libc/src/unistd/linux/setsid.cpp
index df4629bb326c..b1a265c9a01d 100644
--- a/libc/src/unistd/linux/setsid.cpp
+++ b/libc/src/unistd/linux/setsid.cpp
@@ -11,6 +11,7 @@
#include "hdr/types/pid_t.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
#include <sys/syscall.h> // For syscall numbers.
@@ -18,7 +19,12 @@
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(pid_t, setsid, ()) {
- return LIBC_NAMESPACE::syscall_impl<pid_t>(SYS_setsid);
+ pid_t ret = LIBC_NAMESPACE::syscall_impl<pid_t>(SYS_setsid);
+ if (ret < 0) {
+ libc_errno = static_cast<int>(-ret);
+ return -1;
+ }
+ return ret;
}
} // namespace LIBC_NAMESPACE_DECL