Merge pull request #25217 from blblack/setsiderr

std.os.linux.setsid(): return raw syscall0 result
This commit is contained in:
Andrew Kelley 2025-09-17 21:14:08 -07:00 committed by GitHub
commit d2e4ad613b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View file

@ -1834,20 +1834,23 @@ pub fn setgroups(size: usize, list: [*]const gid_t) usize {
}
}
pub fn setsid() pid_t {
return @bitCast(@as(u32, @truncate(syscall0(.setsid))));
pub fn setsid() usize {
return syscall0(.setsid);
}
pub fn getpid() pid_t {
return @bitCast(@as(u32, @truncate(syscall0(.getpid))));
// Casts result to a pid_t, safety-checking >= 0, because getpid() cannot fail
return @intCast(@as(u32, @truncate(syscall0(.getpid))));
}
pub fn getppid() pid_t {
return @bitCast(@as(u32, @truncate(syscall0(.getppid))));
// Casts result to a pid_t, safety-checking >= 0, because getppid() cannot fail
return @intCast(@as(u32, @truncate(syscall0(.getppid))));
}
pub fn gettid() pid_t {
return @bitCast(@as(u32, @truncate(syscall0(.gettid))));
// Casts result to a pid_t, safety-checking >= 0, because gettid() cannot fail
return @intCast(@as(u32, @truncate(syscall0(.gettid))));
}
pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?*sigset_t) usize {

View file

@ -7000,7 +7000,7 @@ pub const SetSidError = error{
pub fn setsid() SetSidError!pid_t {
const rc = system.setsid();
switch (errno(rc)) {
.SUCCESS => return rc,
.SUCCESS => return @intCast(rc),
.PERM => return error.PermissionDenied,
else => |err| return unexpectedErrno(err),
}