diff --git a/mod.zig b/mod.zig index a7114f54e610444303a38aba01c6aae84d424eda..59e100db36f2143cad66209249c8dca0e1b2df1d 100644 --- a/mod.zig +++ b/mod.zig @@ -1271,6 +1271,10 @@ pub const libc = struct { /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/erfl.html pub extern fn erfl(x: c_longdouble) c_longdouble; + /// int execvp(const char *file, char *const argv[]); + /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/execvp.html + pub extern fn execvp(file: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) c_int; + /// void exit(int status); /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/exit.html pub extern fn exit(status: c_int) noreturn; @@ -3605,3 +3609,8 @@ pub fn fchdir(fildes: c_int) !void { if (rc == -1) return errno.fromInt(errno.fromLibC()); std.debug.assert(rc == 0); } +pub fn execvp(file: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) !noreturn { + const rc = libc.execvp(file, argv); + std.debug.assert(rc == -1); + return errno.fromInt(errno.fromLibC()); +} diff --git a/test.zig b/test.zig index 964b57c51450cbfb874425f20c07d74e35c6f910..a8b9a6e12fe185cd8c920d606b59b582ae7f14a3 100644 --- a/test.zig +++ b/test.zig @@ -74,4 +74,5 @@ test { _ = &linux.kill; _ = &linux.fork; _ = &linux.fchdir; + _ = &linux.execvp; }