Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/std/os/linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/std/posix.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down