zig icon indicating copy to clipboard operation
zig copied to clipboard

Added std.os.linux.sigtimedwait

Open GrayHatter opened this issue 4 months ago • 1 comments

I wanted to name this fn sigTimedWait to match zig style. But decided not to given all (most?) other functions here duplicate the C-API style.

I'm not up to date on the current recommendations for how the stdlib should look. I considered introducing SigSet, as a full zig struct similar to the packed struct in std.os.linux.MAP but didn't here to keep this commit unobjectionable.

GrayHatter avatar Nov 16 '25 19:11 GrayHatter

@andrewrk can I get a bit more of a hint about which direction you'd like to see the changes?

directly above the new fn is

pub fn gettid() pid_t {
    // Casts result to a pid_t, safety-checking >= 0, because gettid() cannot fail
    return @intCast(@as(u32, @truncate(syscall0(.gettid))));
}

and below is

pub fn sigaction(sig: SIG, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) usize {
  // ...
    if (E.init(result) != .SUCCESS) return result;

    if (oact) |old| {
        old.handler.handler = oldksa.handler;
        old.flags = oldksa.flags;
        old.mask = oldksa.mask;
    }

    return 0;
}

I believe that the shape of this function resembles the latter? Which convention would you prefer?

GrayHatter avatar Nov 20 '25 23:11 GrayHatter