authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-04-20 16:42:54 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-04-20 16:42:54 -07:00
loge4a20839eb7acf88901557e0aa4561add16e17b7
tree107969b39f5b26442d2bc10a932eb24a8b08e9c4
parent4c2443935160b023dc181890a2a057b06942c67b

add fork


2 files changed, 8 insertions(+), 1 deletions(-)

mod.zig+7-1
......@@ -334,7 +334,13 @@ pub const clone = @compileError("TODO: clone");
334334// fork
335335// pid_t fork(void);
336336// asmlinkage long sys_fork(void);
337pub const fork = @compileError("TODO: fork");
337pub fn fork() errno.Error!pid_t {
338 const r = syscall0(.fork);
339 return switch (_errno(r)) {
340 .ok => @intCast(r),
341 _ => |c| errno.errorFromInt(@intFromEnum(c)),
342 };
343}
338344
339345// vfork
340346// pid_t vfork(void);
test.zig+1
......@@ -10,4 +10,5 @@ test {
1010 _ = &linux.sched_yield;
1111 _ = &linux.pause;
1212 _ = &linux.getpid;
13 _ = &linux.fork;
1314}