File tree Expand file tree Collapse file tree 4 files changed +28
-9
lines changed
Expand file tree Collapse file tree 4 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,8 @@ pub fn getpid() u32 {
141141 return tos .pid ;
142142}
143143pub const SIG = struct {
144+ /// Invalid signal. Used in kill to perform checking without sending signal.
145+ pub const INVAL = 0 ;
144146 /// hangup
145147 pub const HUP = 1 ;
146148 /// interrupt
Original file line number Diff line number Diff line change @@ -980,12 +980,3 @@ const CommonOpenFlags = packed struct {
980980 return result ;
981981 }
982982};
983-
984- test "kill 0 can be used to perform checks of sending signal" {
985- if (native_os == .wasi ) return error .SkipZigTest ;
986- if (native_os == .windows ) return error .SkipZigTest ;
987- posix .kill (posix .getpid (), .INVAL ) catch | err | switch (err ) {
988- posix .KillError .PermissionDenied = > return ,
989- else = > return err ,
990- };
991- }
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ const cases = [_]Case{
2020 .{
2121 .src_path = "relpaths.zig" ,
2222 },
23+ .{
24+ .src_path = "kill.zig" ,
25+ },
2326};
2427
2528pub fn build (b : * std.Build ) void {
Original file line number Diff line number Diff line change 1+ const std = @import ("std" );
2+ const posix = std .posix ;
3+ const builtin = @import ("builtin" );
4+
5+ const path_max = std .fs .max_path_bytes ;
6+
7+ pub fn main () ! void {
8+ try test_kill_zero_self_should_succeed ();
9+ try test_kill_nonexistent ();
10+ }
11+
12+ fn test_kill_nonexistent () ! void {
13+ const impossible_pid : posix.pid_t = 1_999_999_999 ;
14+ posix .kill (impossible_pid , .INVAL ) catch | err | switch (err ) {
15+ posix .KillError .ProcessNotFound = > return ,
16+ else = > return err ,
17+ };
18+ return error .ProcessShouldHaveNotBeenFound ;
19+ }
20+
21+ fn test_kill_zero_self_should_succeed () ! void {
22+ try posix .kill (posix .getpid (), .INVAL );
23+ }
You can’t perform that action at this time.
0 commit comments