mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Limit test to OS with known maximum PID. Omit windows from kill 0 test
This commit is contained in:
parent
2f738eb877
commit
cdb85b2c87
1 changed files with 8 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
|||
const std = @import("std");
|
||||
const posix = std.posix;
|
||||
const builtin = @import("builtin");
|
||||
const native_os = builtin.target.os.tag;
|
||||
|
||||
pub fn main() !void {
|
||||
try test_kill_zero_self_should_succeed();
|
||||
|
|
@ -7,6 +9,10 @@ pub fn main() !void {
|
|||
}
|
||||
|
||||
fn test_kill_nonexistent() !void {
|
||||
if ((native_os != .linux) and (native_os != .macos)) return;
|
||||
// Linux is limited by PID_MAX_LIMIT constant which is around 4 million
|
||||
// MacOS maximum pid appears to be 99999 and not configurable.
|
||||
// Others are unknown thus not tested.
|
||||
const impossible_pid: posix.pid_t = 1_999_999_999;
|
||||
posix.kill(impossible_pid, .INVAL) catch |err| switch (err) {
|
||||
posix.KillError.ProcessNotFound => return,
|
||||
|
|
@ -16,5 +22,7 @@ fn test_kill_nonexistent() !void {
|
|||
}
|
||||
|
||||
fn test_kill_zero_self_should_succeed() !void {
|
||||
// Windows does not have kill -0 equivalent
|
||||
if (native_os == .windows) return;
|
||||
try posix.kill(posix.getpid(), .INVAL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue