Skip to content

std.posix.kill does not allow signal 0 #26011

@psznm

Description

@psznm

Zig Version

0.16.0-dev.1424+d3e20e71b

Steps to Reproduce and Observed Behavior

From man 2 kill

If sig is 0, then no signal is sent, but existence and permission checks are still performed; this can be used to check for the existence of a process ID or process group ID that the caller is permitted to signal.

Since zig 0.16 is converting signal to exhaustive enum, the signal 0 is not allowed, so I was unable to migrate a function (without examining kill implementaion and reimplementing with syscall that is used internally)

fn pidIsRunning(pid: std.c.pid_t) !bool {
    const Err = std.posix.KillError;
    std.posix.kill(pid, 0) catch |err| switch (err) {
        Err.PermissionDenied => return true,
        Err.ProcessNotFound => return false,
        Err.Unexpected => return err,
    };
    return true;
}

Expected Behavior

Signal 0 should be allowed in kill to skip sending signal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions