mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Merge a79ccf9679 into d0ba6642b5
This commit is contained in:
commit
88d08b7ff8
5 changed files with 43 additions and 0 deletions
|
|
@ -2662,6 +2662,8 @@ pub const SIG = switch (native_os) {
|
||||||
pub const IOT: SIG = .ABRT;
|
pub const IOT: SIG = .ABRT;
|
||||||
pub const POLL: SIG = .EMT;
|
pub const POLL: SIG = .EMT;
|
||||||
|
|
||||||
|
/// Invalid signal. Used in kill to perform checking without sending signal.
|
||||||
|
INVAL = 0,
|
||||||
/// hangup
|
/// hangup
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
/// interrupt
|
/// interrupt
|
||||||
|
|
@ -2756,6 +2758,7 @@ pub const SIG = switch (native_os) {
|
||||||
pub const RTMIN = 65;
|
pub const RTMIN = 65;
|
||||||
pub const RTMAX = 126;
|
pub const RTMAX = 126;
|
||||||
|
|
||||||
|
INVAL = 0,
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
INT = 2,
|
INT = 2,
|
||||||
QUIT = 3,
|
QUIT = 3,
|
||||||
|
|
@ -2821,6 +2824,7 @@ pub const SIG = switch (native_os) {
|
||||||
|
|
||||||
pub const POLL: SIG = .IO;
|
pub const POLL: SIG = .IO;
|
||||||
|
|
||||||
|
INVAL = 0,
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
INT = 2,
|
INT = 2,
|
||||||
QUIT = 3,
|
QUIT = 3,
|
||||||
|
|
@ -2895,6 +2899,7 @@ pub const SIG = switch (native_os) {
|
||||||
|
|
||||||
pub const IOT: SIG = .ABRT;
|
pub const IOT: SIG = .ABRT;
|
||||||
|
|
||||||
|
INVAL = 0,
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
INT = 2,
|
INT = 2,
|
||||||
QUIT = 3,
|
QUIT = 3,
|
||||||
|
|
@ -2941,6 +2946,7 @@ pub const SIG = switch (native_os) {
|
||||||
|
|
||||||
pub const IOT: SIG = .ABRT;
|
pub const IOT: SIG = .ABRT;
|
||||||
|
|
||||||
|
INVAL = 0,
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
INT = 2,
|
INT = 2,
|
||||||
QUIT = 3,
|
QUIT = 3,
|
||||||
|
|
@ -2989,6 +2995,7 @@ pub const SIG = switch (native_os) {
|
||||||
|
|
||||||
pub const IOT: SIG = .ABRT;
|
pub const IOT: SIG = .ABRT;
|
||||||
|
|
||||||
|
INVAL = 0,
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
INT = 2,
|
INT = 2,
|
||||||
QUIT = 3,
|
QUIT = 3,
|
||||||
|
|
@ -3035,6 +3042,7 @@ pub const SIG = switch (native_os) {
|
||||||
|
|
||||||
pub const IOT: SIG = .ABRT;
|
pub const IOT: SIG = .ABRT;
|
||||||
|
|
||||||
|
INVAL = 0,
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
INT = 2,
|
INT = 2,
|
||||||
QUIT = 3,
|
QUIT = 3,
|
||||||
|
|
|
||||||
|
|
@ -3741,6 +3741,8 @@ pub const SIG = if (is_mips) enum(u32) {
|
||||||
pub const IOT: SIG = .ABRT;
|
pub const IOT: SIG = .ABRT;
|
||||||
pub const POLL: SIG = .IO;
|
pub const POLL: SIG = .IO;
|
||||||
|
|
||||||
|
INVAL = 0,
|
||||||
|
|
||||||
// /arch/mips/include/uapi/asm/signal.h#L25
|
// /arch/mips/include/uapi/asm/signal.h#L25
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
INT = 2,
|
INT = 2,
|
||||||
|
|
@ -3787,6 +3789,8 @@ pub const SIG = if (is_mips) enum(u32) {
|
||||||
pub const PWR: SIG = .LOST;
|
pub const PWR: SIG = .LOST;
|
||||||
pub const POLL: SIG = .IO;
|
pub const POLL: SIG = .IO;
|
||||||
|
|
||||||
|
/// Perform error checking without sending signal.
|
||||||
|
INVAL = 0,
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
INT = 2,
|
INT = 2,
|
||||||
QUIT = 3,
|
QUIT = 3,
|
||||||
|
|
@ -3830,6 +3834,8 @@ pub const SIG = if (is_mips) enum(u32) {
|
||||||
pub const POLL: SIG = .IO;
|
pub const POLL: SIG = .IO;
|
||||||
pub const IOT: SIG = .ABRT;
|
pub const IOT: SIG = .ABRT;
|
||||||
|
|
||||||
|
/// Perform error checking without sending signal.
|
||||||
|
INVAL = 0,
|
||||||
HUP = 1,
|
HUP = 1,
|
||||||
INT = 2,
|
INT = 2,
|
||||||
QUIT = 3,
|
QUIT = 3,
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,8 @@ pub fn getpid() u32 {
|
||||||
return tos.pid;
|
return tos.pid;
|
||||||
}
|
}
|
||||||
pub const SIG = struct {
|
pub const SIG = struct {
|
||||||
|
/// Invalid signal. Used in kill to perform checking without sending signal.
|
||||||
|
pub const INVAL = 0;
|
||||||
/// hangup
|
/// hangup
|
||||||
pub const HUP = 1;
|
pub const HUP = 1;
|
||||||
/// interrupt
|
/// interrupt
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ const cases = [_]Case{
|
||||||
.{
|
.{
|
||||||
.src_path = "relpaths.zig",
|
.src_path = "relpaths.zig",
|
||||||
},
|
},
|
||||||
|
.{
|
||||||
|
.src_path = "kill.zig",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
|
|
|
||||||
24
test/standalone/posix/kill.zig
Normal file
24
test/standalone/posix/kill.zig
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
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();
|
||||||
|
try test_kill_nonexistent();
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
try std.testing.expectError(posix.KillError.ProcessNotFound, posix.kill(impossible_pid, .INVAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
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