diff --git a/libc/Makefile b/libc/Makefile index 79f4eb35..da4cfe0c 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -702,6 +702,7 @@ unistd/fchownat.o \ unistd/fchown.o \ unistd/fchrootat.o \ unistd/fchroot.o \ +unistd/_Fork.o \ unistd/fork.o \ unistd/fpathconf.o \ unistd/fsync.o \ diff --git a/libc/include/unistd.h b/libc/include/unistd.h index 21c0beea..56476b12 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -533,6 +533,7 @@ int unlinkat(int, const char*, int); /* Functions from POSIX 2024. */ #if __USE_SORTIX || 202405L <= __USE_POSIX +pid_t _Fork(void); int dup3(int, int, int); int getentropy(void*, size_t); int pipe2(int [2], int); diff --git a/libc/unistd/_Fork.c b/libc/unistd/_Fork.c new file mode 100644 index 00000000..29a6cb8f --- /dev/null +++ b/libc/unistd/_Fork.c @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2011, 2012, 2024 Jonas 'Sortie' Termansen. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * unistd/_Fork.c + * Create a new task inheriting some properties from the current task. + */ + +#include + +pid_t _Fork(void) +{ + return sfork(SFFORK); +} diff --git a/libc/unistd/fork.c b/libc/unistd/fork.c index 19995db8..564a16fb 100644 --- a/libc/unistd/fork.c +++ b/libc/unistd/fork.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012 Jonas 'Sortie' Termansen. + * Copyright (c) 2011, 2012, 2024 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,5 +21,5 @@ pid_t fork(void) { - return sfork(SFFORK); + return _Fork(); }