authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-26 17:59:38 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-26 17:59:52 -07:00
log917a00d70c663a959c8aee6c80cf79feba7d2314
treed0349cf64fdf968ed48607a56d74ed38df663755
parentf340bdfff52c148a94fcb844b80d9048bd419e79
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add kill


2 files changed, 47 insertions(+), 0 deletions(-)

mod.zig+46
......@@ -1895,6 +1895,10 @@ pub const libc = struct {
18951895 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/jn.html
18961896 pub extern fn jn(n: c_int, x: f64) f64;
18971897
1898 /// int kill(pid_t pid, int sig);
1899 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/kill.html
1900 pub extern fn kill(pid: pid_t, sig: c_int) c_int;
1901
18981902 /// long labs(long i);
18991903 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/labs.html
19001904 pub extern fn labs(i: c_long) c_long;
......@@ -3205,6 +3209,43 @@ pub const LOCK = struct {
32053209 pub const UN = 8;
32063210};
32073211
3212pub const SIG = struct {
3213 pub const HUP = 1;
3214 pub const INT = 2;
3215 pub const QUIT = 3;
3216 pub const ILL = 4;
3217 pub const TRAP = 5;
3218 pub const ABRT = 6;
3219 pub const IOT = ABRT;
3220 pub const BUS = 7;
3221 pub const FPE = 8;
3222 pub const KILL = 9;
3223 pub const USR1 = 10;
3224 pub const SEGV = 11;
3225 pub const USR2 = 12;
3226 pub const PIPE = 13;
3227 pub const ALRM = 14;
3228 pub const TERM = 15;
3229 pub const STKFLT = 16;
3230 pub const CHLD = 17;
3231 pub const CONT = 18;
3232 pub const STOP = 19;
3233 pub const TSTP = 20;
3234 pub const TTIN = 21;
3235 pub const TTOU = 22;
3236 pub const URG = 23;
3237 pub const XCPU = 24;
3238 pub const XFSZ = 25;
3239 pub const VTALRM = 26;
3240 pub const PROF = 27;
3241 pub const WINCH = 28;
3242 pub const IO = 29;
3243 pub const POLL = 29;
3244 pub const PWR = 30;
3245 pub const SYS = 31;
3246 pub const UNUSED = SYS;
3247};
3248
32083249pub fn getpid() pid_t {
32093250 return libc.getpid();
32103251}
......@@ -3548,3 +3589,8 @@ pub fn pipe2(flag: c_int) ![2]c_int {
35483589 std.debug.assert(rc == 0);
35493590 return fildes;
35503591}
3592pub fn kill(pid: pid_t, sig: c_int) !void {
3593 const rc = libc.kill(pid, sig);
3594 if (rc == -1) return errno.fromInt(errno.fromLibC());
3595 std.debug.assert(rc == 0);
3596}
test.zig+1
......@@ -71,4 +71,5 @@ test {
7171 _ = &linux.pthread_rwlock_trywrlock;
7272 _ = &linux.pthread_rwlock_unlock;
7373 _ = &linux.pipe2;
74 _ = &linux.kill;
7475}