Add _Fork(2).

This commit is contained in:
Jonas 'Sortie' Termansen 2024-06-23 13:40:39 +02:00
parent 82fd2d4c92
commit c4a44531bf
4 changed files with 29 additions and 2 deletions

View File

@ -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 \

View File

@ -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);

25
libc/unistd/_Fork.c Normal file
View File

@ -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 <unistd.h>
pid_t _Fork(void)
{
return sfork(SFFORK);
}

View File

@ -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();
}