* _Fork()
@ 2024-02-29 22:12 enh
2024-02-29 22:49 ` _Fork() Alejandro Colomar
0 siblings, 1 reply; 5+ messages in thread
From: enh @ 2024-02-29 22:12 UTC (permalink / raw)
To: linux-man
(apologies for the post without a patch but...)
fyi, i noticed that there's no reference to _Fork() anywhere. i'd send
a patch, but given that vfork() has a page to itself, i'm assuming
just adding a paragraph to fork(2) isn't the plan?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: _Fork()
2024-02-29 22:12 _Fork() enh
@ 2024-02-29 22:49 ` Alejandro Colomar
2024-02-29 23:14 ` _Fork() enh
0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2024-02-29 22:49 UTC (permalink / raw)
To: enh; +Cc: linux-man
[-- Attachment #1: Type: text/plain, Size: 638 bytes --]
Hi Elliott,
On Thu, Feb 29, 2024 at 02:12:12PM -0800, enh wrote:
> (apologies for the post without a patch but...)
No worries. :)
> fyi, i noticed that there's no reference to _Fork() anywhere. i'd send
> a patch, but given that vfork() has a page to itself, i'm assuming
> just adding a paragraph to fork(2) isn't the plan?
Hmmm, I didn't know about the existence of _Fork(). It looks like
_Exit(3) and exit(3), right? Maybe we could write a page based on
_Exit(3). What do you think?
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es/>
Looking for a remote C programming job at the moment.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: _Fork()
2024-02-29 22:49 ` _Fork() Alejandro Colomar
@ 2024-02-29 23:14 ` enh
2025-05-24 18:46 ` _Fork() Alejandro Colomar
0 siblings, 1 reply; 5+ messages in thread
From: enh @ 2024-02-29 23:14 UTC (permalink / raw)
To: Alejandro Colomar; +Cc: linux-man
On Thu, Feb 29, 2024 at 2:49 PM Alejandro Colomar <alx@kernel.org> wrote:
>
> Hi Elliott,
>
> On Thu, Feb 29, 2024 at 02:12:12PM -0800, enh wrote:
> > (apologies for the post without a patch but...)
>
> No worries. :)
>
> > fyi, i noticed that there's no reference to _Fork() anywhere. i'd send
> > a patch, but given that vfork() has a page to itself, i'm assuming
> > just adding a paragraph to fork(2) isn't the plan?
>
> Hmmm, I didn't know about the existence of _Fork(). It looks like
> _Exit(3) and exit(3), right? Maybe we could write a page based on
> _Exit(3). What do you think?
in the "don't do that other stuff" sense, yes --- here's what i wrote
for the doc comment in Android's <unistd.h>:
/**
* _Fork() creates a new process. _Fork() differs from fork() in that it does
* not run any handlers set by pthread_atfork().
*
* Returns 0 in the child, the pid of the child in the parent,
* and returns -1 and sets `errno` on failure.
*
* Available since API level 35.
*/
pid_t _Fork(void) __INTRODUCED_IN(35);
looks like glibc has a bit more:
https://www.gnu.org/software/libc/manual/html_node/Creating-a-Process.html
The _Fork function is similar to fork, but it does not invoke any
callbacks registered with pthread_atfork, nor does it reset any
internal state or locks (such as the malloc locks). In the new
subprocess, only async-signal-safe functions may be called, such as
dup2 or execve.
The _Fork function is an async-signal-safe replacement of fork. It
is a GNU extension.
whereas i assumed that everyone knows that bionic's internal state
resetting is done via pthread_atfork() which, in retrospect, is
probably an unreasonable assumption /facepalm
annoyingly, while this is slated for POSIX issue 8
(https://austingroupbugs.net/view.php?id=62) it's not there yet, so
there's nothing public to point to there.
> Have a lovely night!
> Alex
>
> --
> <https://www.alejandro-colomar.es/>
> Looking for a remote C programming job at the moment.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: _Fork()
2024-02-29 23:14 ` _Fork() enh
@ 2025-05-24 18:46 ` Alejandro Colomar
2025-05-27 13:48 ` _Fork() enh
0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2025-05-24 18:46 UTC (permalink / raw)
To: enh; +Cc: linux-man
[-- Attachment #1: Type: text/plain, Size: 10068 bytes --]
Hey Elliott!
On Thu, Feb 29, 2024 at 03:14:30PM -0800, enh wrote:
> On Thu, Feb 29, 2024 at 2:49 PM Alejandro Colomar <alx@kernel.org> wrote:
> >
> > Hi Elliott,
> >
> > On Thu, Feb 29, 2024 at 02:12:12PM -0800, enh wrote:
> > > (apologies for the post without a patch but...)
> >
> > No worries. :)
> >
> > > fyi, i noticed that there's no reference to _Fork() anywhere. i'd send
> > > a patch, but given that vfork() has a page to itself, i'm assuming
> > > just adding a paragraph to fork(2) isn't the plan?
> >
> > Hmmm, I didn't know about the existence of _Fork(). It looks like
> > _Exit(3) and exit(3), right? Maybe we could write a page based on
> > _Exit(3). What do you think?
>
> in the "don't do that other stuff" sense, yes --- here's what i wrote
> for the doc comment in Android's <unistd.h>:
I had kept this in my mailbox to eventually do it...
And this month I've been working on updating the manual pages for
POSIX.1-2024. During that, I met the _Fork() function, and have added a
small manual page for it.
Here's the main change, which adds _Fork(3):
alx@devuan:/srv/alx/src/linux/man-pages/man-pages/posix24$ git show 7b0fc2aa3078
commit 7b0fc2aa3078d7d4ffbe0e8ecdac59816c8c6f48
Author: Alejandro Colomar <alx@kernel.org>
Date: Sat May 17 14:09:14 2025 +0200
man/man3/_Fork.3: Document _Fork()
Signed-off-by: Alejandro Colomar <alx@kernel.org>
diff --git a/man/man3/_Fork.3 b/man/man3/_Fork.3
new file mode 100644
index 000000000..95b0bc61b
--- /dev/null
+++ b/man/man3/_Fork.3
@@ -0,0 +1,29 @@
+.\" Copyright, The authors of the Linux man-pages project
+.\"
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.TH _Fork 3 (date) "Linux man-pages (unreleased)"
+.SH NAME
+_Fork \- create a child process
+.SH LIBRARY
+Standard C library
+.RI ( libc ,\~ \-lc )
+.SH SYNOPSIS
+.nf
+.B #include <unistd.h>
+.P
+.B pid_t _Fork(void);
+.fi
+.SH DESCRIPTION
+This function is equivalent to
+.BR fork (2),
+except that fork handlers registered with
+.BR pthread_atfork (3)
+are not called.
+.SH STANDARDS
+POSIX.1-2024.
+.SH HISTORY
+POSIX.1-2024.
+.SH SEE ALSO
+.BR fork (2),
+.BR vfork (2)
which renders as
alx@devuan:/srv/alx/src/linux/man-pages/man-pages/posix24$ MANWIDTH=72 diffman-git 7b0fc2aa3078
fatal: path 'man/man3/_Fork.3' exists on disk, but not in '7b0fc2aa3078^'
--- 7b0fc2aa3078^:man/man3/_Fork.3
+++ 7b0fc2aa3078:man/man3/_Fork.3
@@ -0,0 +1,27 @@
+_Fork(3) Library Functions Manual _Fork(3)
+
+NAME
+ _Fork - create a child process
+
+LIBRARY
+ Standard C library (libc, -lc)
+
+SYNOPSIS
+ #include <unistd.h>
+
+ pid_t _Fork(void);
+
+DESCRIPTION
+ This function is equivalent to fork(2), except that fork handlers
+ registered with pthread_atfork(3) are not called.
+
+STANDARDS
+ POSIX.1‐2024.
+
+HISTORY
+ POSIX.1‐2024.
+
+SEE ALSO
+ fork(2), vfork(2)
+
+Linux man‐pages (unreleased) (date) _Fork(3)
and then a second change which updates existing pages:
alx@devuan:/srv/alx/src/linux/man-pages/man-pages/posix24$ git show e480a82ad75a
commit e480a82ad75af215c00c512c925c198efa21a007
Author: Alejandro Colomar <alx@kernel.org>
Date: Sat May 17 14:10:49 2025 +0200
man/: Update fork(2) for POSIX.1-2024, and add references to _Fork(3)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
diff --git a/man/man2/fork.2 b/man/man2/fork.2
index c5eeaca10..f81489859 100644
--- a/man/man2/fork.2
+++ b/man/man2/fork.2
@@ -270,8 +270,12 @@ .SS C library/kernel differences
established using
.BR pthread_atfork (3).
.\" and does some magic to ensure that getpid(2) returns the right value.
+.SS Async-signal safety
+.BR _Fork (3)
+is an async-signal safe variant of
+.BR fork (2).
.SH STANDARDS
-POSIX.1-2008.
+POSIX.1-2024.
.SH HISTORY
POSIX.1-2001, SVr4, 4.3BSD.
.SH NOTES
@@ -332,6 +336,7 @@ .SH SEE ALSO
.BR vfork (2),
.BR wait (2),
.BR daemon (3),
+.BR _Fork (3),
.BR pthread_atfork (3),
.BR capabilities (7),
.BR credentials (7)
diff --git a/man/man2/vfork.2 b/man/man2/vfork.2
index bb8722826..a1025cac6 100644
--- a/man/man2/vfork.2
+++ b/man/man2/vfork.2
@@ -308,5 +308,6 @@ .SH SEE ALSO
.BR execve (2),
.BR _exit (2),
.BR fork (2),
+.BR _Fork (3),
.BR unshare (2),
.BR wait (2)
diff --git a/man/man7/signal-safety.7 b/man/man7/signal-safety.7
index c7d5ef10d..d844d2725 100644
--- a/man/man7/signal-safety.7
+++ b/man/man7/signal-safety.7
@@ -115,7 +115,7 @@ .SH DESCRIPTION
\f[B]fdatasync\f[](2)
\f[B]fexecve\f[](3) Added in POSIX.1-2008
\f[B]ffs\f[](3) Added in POSIX.1-2008 TC2
-\f[B]fork\f[](2) See notes below
+\f[B]_Fork\f[](3)
\f[B]fstat\f[](2)
\f[B]fstatat\f[](2) Added in POSIX.1-2008
\f[B]fsync\f[](2)
@@ -295,18 +295,6 @@ .SH DESCRIPTION
.BR siglongjmp (3)
and the program subsequently calls an unsafe function,
then the behavior of the program is undefined.
-.IP \[bu]
-POSIX.1-2001 TC1 clarified
-that if an application calls
-.BR fork (2)
-from a signal handler and any of the fork handlers registered by
-.BR pthread_atfork (3)
-calls a function that is not async-signal-safe, the behavior is undefined.
-A future revision of the standard
-.\" http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt
-is likely to remove
-.BR fork (2)
-from the list of async-signal-safe functions.
.\"
.IP \[bu]
Asynchronous signal handlers that call functions which are cancelation
which renders as
alx@devuan:/srv/alx/src/linux/man-pages/man-pages/posix24$ MANWIDTH=72 diffman-git e480a82ad75a
--- e480a82ad75a^:man/man2/fork.2
+++ e480a82ad75a:man/man2/fork.2
@@ -177,8 +177,11 @@
just SIGCHLD.) The glibc wrapper invokes any fork handlers that
have been established using pthread_atfork(3).
+ Async‐signal safety
+ _Fork(3) is an async‐signal safe variant of fork(2).
+
STANDARDS
- POSIX.1‐2008.
+ POSIX.1‐2024.
HISTORY
POSIX.1‐2001, SVr4, 4.3BSD.
@@ -226,7 +229,7 @@
SEE ALSO
clone(2), execve(2), exit(2), _exit(2), setrlimit(2), unshare(2),
- vfork(2), wait(2), daemon(3), pthread_atfork(3), capabilities(7),
- credentials(7)
+ vfork(2), wait(2), daemon(3), _Fork(3), pthread_atfork(3), capa‐
+ bilities(7), credentials(7)
Linux man‐pages (unreleased) (date) fork(2)
--- e480a82ad75a^:man/man2/vfork.2
+++ e480a82ad75a:man/man2/vfork.2
@@ -178,6 +178,7 @@
tion."
SEE ALSO
- clone(2), execve(2), _exit(2), fork(2), unshare(2), wait(2)
+ clone(2), execve(2), _exit(2), fork(2), _Fork(3), unshare(2),
+ wait(2)
Linux man‐pages (unreleased) (date) vfork(2)
--- e480a82ad75a^:man/man7/signal-safety.7
+++ e480a82ad75a:man/man7/signal-safety.7
@@ -92,7 +92,7 @@
fdatasync(2)
fexecve(3) Added in POSIX.1‐2008
ffs(3) Added in POSIX.1‐2008 TC2
- fork(2) See notes below
+ _Fork(3)
fstat(2)
fstatat(2) Added in POSIX.1‐2008
fsync(2)
@@ -260,13 +260,6 @@
siglongjmp(3) and the program subsequently calls an unsafe
function, then the behavior of the program is undefined.
- • POSIX.1‐2001 TC1 clarified that if an application calls fork(2)
- from a signal handler and any of the fork handlers registered
- by pthread_atfork(3) calls a function that is not async‐signal‐
- safe, the behavior is undefined. A future revision of the
- standard is likely to remove fork(2) from the list of async‐
- signal‐safe functions.
-
• Asynchronous signal handlers that call functions which are can‐
celation points and nest over regions of deferred cancelation
may trigger cancelation whose behavior is as if asynchronous
This is pushed in the posix24 branch, where I'm still working on the
updates for POSIX.1-2024 (so if you find anything you'd like to amend,
we're still in time).
<https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/log/?h=posix24>
>
> /**
> * _Fork() creates a new process. _Fork() differs from fork() in that it does
> * not run any handlers set by pthread_atfork().
> *
> * Returns 0 in the child, the pid of the child in the parent,
> * and returns -1 and sets `errno` on failure.
> *
> * Available since API level 35.
> */
> pid_t _Fork(void) __INTRODUCED_IN(35);
>
> looks like glibc has a bit more:
>
> https://www.gnu.org/software/libc/manual/html_node/Creating-a-Process.html
>
> The _Fork function is similar to fork, but it does not invoke any
> callbacks registered with pthread_atfork, nor does it reset any
> internal state or locks (such as the malloc locks). In the new
> subprocess, only async-signal-safe functions may be called, such as
> dup2 or execve.
>
> The _Fork function is an async-signal-safe replacement of fork. It
> is a GNU extension.
>
> whereas i assumed that everyone knows that bionic's internal state
> resetting is done via pthread_atfork() which, in retrospect, is
> probably an unreasonable assumption /facepalm
>
> annoyingly, while this is slated for POSIX issue 8
> (https://austingroupbugs.net/view.php?id=62) it's not there yet, so
> there's nothing public to point to there.
POSIX.1-2024 is out now, and our manual page will be there soon. :-)
Have a lovely day!
Alex
>
> > Have a lovely night!
> > Alex
> >
> > --
> > <https://www.alejandro-colomar.es/>
> > Looking for a remote C programming job at the moment.
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: _Fork()
2025-05-24 18:46 ` _Fork() Alejandro Colomar
@ 2025-05-27 13:48 ` enh
0 siblings, 0 replies; 5+ messages in thread
From: enh @ 2025-05-27 13:48 UTC (permalink / raw)
To: Alejandro Colomar; +Cc: linux-man
On Sat, May 24, 2025 at 2:46 PM Alejandro Colomar <alx@kernel.org> wrote:
>
> Hey Elliott!
>
> On Thu, Feb 29, 2024 at 03:14:30PM -0800, enh wrote:
> > On Thu, Feb 29, 2024 at 2:49 PM Alejandro Colomar <alx@kernel.org> wrote:
> > >
> > > Hi Elliott,
> > >
> > > On Thu, Feb 29, 2024 at 02:12:12PM -0800, enh wrote:
> > > > (apologies for the post without a patch but...)
> > >
> > > No worries. :)
> > >
> > > > fyi, i noticed that there's no reference to _Fork() anywhere. i'd send
> > > > a patch, but given that vfork() has a page to itself, i'm assuming
> > > > just adding a paragraph to fork(2) isn't the plan?
> > >
> > > Hmmm, I didn't know about the existence of _Fork(). It looks like
> > > _Exit(3) and exit(3), right? Maybe we could write a page based on
> > > _Exit(3). What do you think?
> >
> > in the "don't do that other stuff" sense, yes --- here's what i wrote
> > for the doc comment in Android's <unistd.h>:
>
> I had kept this in my mailbox to eventually do it...
>
> And this month I've been working on updating the manual pages for
> POSIX.1-2024. During that, I met the _Fork() function, and have added a
> small manual page for it.
>
> Here's the main change, which adds _Fork(3):
>
> alx@devuan:/srv/alx/src/linux/man-pages/man-pages/posix24$ git show 7b0fc2aa3078
> commit 7b0fc2aa3078d7d4ffbe0e8ecdac59816c8c6f48
> Author: Alejandro Colomar <alx@kernel.org>
> Date: Sat May 17 14:09:14 2025 +0200
>
> man/man3/_Fork.3: Document _Fork()
>
> Signed-off-by: Alejandro Colomar <alx@kernel.org>
>
> diff --git a/man/man3/_Fork.3 b/man/man3/_Fork.3
> new file mode 100644
> index 000000000..95b0bc61b
> --- /dev/null
> +++ b/man/man3/_Fork.3
> @@ -0,0 +1,29 @@
> +.\" Copyright, The authors of the Linux man-pages project
> +.\"
> +.\" SPDX-License-Identifier: Linux-man-pages-copyleft
> +.\"
> +.TH _Fork 3 (date) "Linux man-pages (unreleased)"
> +.SH NAME
> +_Fork \- create a child process
> +.SH LIBRARY
> +Standard C library
> +.RI ( libc ,\~ \-lc )
> +.SH SYNOPSIS
> +.nf
> +.B #include <unistd.h>
> +.P
> +.B pid_t _Fork(void);
> +.fi
> +.SH DESCRIPTION
> +This function is equivalent to
> +.BR fork (2),
> +except that fork handlers registered with
> +.BR pthread_atfork (3)
> +are not called.
> +.SH STANDARDS
> +POSIX.1-2024.
> +.SH HISTORY
> +POSIX.1-2024.
> +.SH SEE ALSO
> +.BR fork (2),
> +.BR vfork (2)
>
> which renders as
>
> alx@devuan:/srv/alx/src/linux/man-pages/man-pages/posix24$ MANWIDTH=72 diffman-git 7b0fc2aa3078
> fatal: path 'man/man3/_Fork.3' exists on disk, but not in '7b0fc2aa3078^'
> --- 7b0fc2aa3078^:man/man3/_Fork.3
> +++ 7b0fc2aa3078:man/man3/_Fork.3
> @@ -0,0 +1,27 @@
> +_Fork(3) Library Functions Manual _Fork(3)
> +
> +NAME
> + _Fork - create a child process
> +
> +LIBRARY
> + Standard C library (libc, -lc)
> +
> +SYNOPSIS
> + #include <unistd.h>
> +
> + pid_t _Fork(void);
> +
> +DESCRIPTION
> + This function is equivalent to fork(2), except that fork handlers
> + registered with pthread_atfork(3) are not called.
> +
> +STANDARDS
> + POSIX.1‐2024.
> +
> +HISTORY
> + POSIX.1‐2024.
> +
> +SEE ALSO
> + fork(2), vfork(2)
> +
> +Linux man‐pages (unreleased) (date) _Fork(3)
>
> and then a second change which updates existing pages:
>
> alx@devuan:/srv/alx/src/linux/man-pages/man-pages/posix24$ git show e480a82ad75a
> commit e480a82ad75af215c00c512c925c198efa21a007
> Author: Alejandro Colomar <alx@kernel.org>
> Date: Sat May 17 14:10:49 2025 +0200
>
> man/: Update fork(2) for POSIX.1-2024, and add references to _Fork(3)
>
> Signed-off-by: Alejandro Colomar <alx@kernel.org>
>
> diff --git a/man/man2/fork.2 b/man/man2/fork.2
> index c5eeaca10..f81489859 100644
> --- a/man/man2/fork.2
> +++ b/man/man2/fork.2
> @@ -270,8 +270,12 @@ .SS C library/kernel differences
> established using
> .BR pthread_atfork (3).
> .\" and does some magic to ensure that getpid(2) returns the right value.
> +.SS Async-signal safety
> +.BR _Fork (3)
> +is an async-signal safe variant of
> +.BR fork (2).
> .SH STANDARDS
> -POSIX.1-2008.
> +POSIX.1-2024.
> .SH HISTORY
> POSIX.1-2001, SVr4, 4.3BSD.
> .SH NOTES
> @@ -332,6 +336,7 @@ .SH SEE ALSO
> .BR vfork (2),
> .BR wait (2),
> .BR daemon (3),
> +.BR _Fork (3),
> .BR pthread_atfork (3),
> .BR capabilities (7),
> .BR credentials (7)
> diff --git a/man/man2/vfork.2 b/man/man2/vfork.2
> index bb8722826..a1025cac6 100644
> --- a/man/man2/vfork.2
> +++ b/man/man2/vfork.2
> @@ -308,5 +308,6 @@ .SH SEE ALSO
> .BR execve (2),
> .BR _exit (2),
> .BR fork (2),
> +.BR _Fork (3),
> .BR unshare (2),
> .BR wait (2)
> diff --git a/man/man7/signal-safety.7 b/man/man7/signal-safety.7
> index c7d5ef10d..d844d2725 100644
> --- a/man/man7/signal-safety.7
> +++ b/man/man7/signal-safety.7
> @@ -115,7 +115,7 @@ .SH DESCRIPTION
> \f[B]fdatasync\f[](2)
> \f[B]fexecve\f[](3) Added in POSIX.1-2008
> \f[B]ffs\f[](3) Added in POSIX.1-2008 TC2
> -\f[B]fork\f[](2) See notes below
> +\f[B]_Fork\f[](3)
> \f[B]fstat\f[](2)
> \f[B]fstatat\f[](2) Added in POSIX.1-2008
> \f[B]fsync\f[](2)
> @@ -295,18 +295,6 @@ .SH DESCRIPTION
> .BR siglongjmp (3)
> and the program subsequently calls an unsafe function,
> then the behavior of the program is undefined.
> -.IP \[bu]
> -POSIX.1-2001 TC1 clarified
> -that if an application calls
> -.BR fork (2)
> -from a signal handler and any of the fork handlers registered by
> -.BR pthread_atfork (3)
> -calls a function that is not async-signal-safe, the behavior is undefined.
> -A future revision of the standard
> -.\" http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt
> -is likely to remove
> -.BR fork (2)
> -from the list of async-signal-safe functions.
> .\"
> .IP \[bu]
> Asynchronous signal handlers that call functions which are cancelation
>
> which renders as
>
> alx@devuan:/srv/alx/src/linux/man-pages/man-pages/posix24$ MANWIDTH=72 diffman-git e480a82ad75a
> --- e480a82ad75a^:man/man2/fork.2
> +++ e480a82ad75a:man/man2/fork.2
> @@ -177,8 +177,11 @@
> just SIGCHLD.) The glibc wrapper invokes any fork handlers that
> have been established using pthread_atfork(3).
>
> + Async‐signal safety
> + _Fork(3) is an async‐signal safe variant of fork(2).
> +
> STANDARDS
> - POSIX.1‐2008.
> + POSIX.1‐2024.
>
> HISTORY
> POSIX.1‐2001, SVr4, 4.3BSD.
> @@ -226,7 +229,7 @@
>
> SEE ALSO
> clone(2), execve(2), exit(2), _exit(2), setrlimit(2), unshare(2),
> - vfork(2), wait(2), daemon(3), pthread_atfork(3), capabilities(7),
> - credentials(7)
> + vfork(2), wait(2), daemon(3), _Fork(3), pthread_atfork(3), capa‐
> + bilities(7), credentials(7)
>
> Linux man‐pages (unreleased) (date) fork(2)
> --- e480a82ad75a^:man/man2/vfork.2
> +++ e480a82ad75a:man/man2/vfork.2
> @@ -178,6 +178,7 @@
> tion."
>
> SEE ALSO
> - clone(2), execve(2), _exit(2), fork(2), unshare(2), wait(2)
> + clone(2), execve(2), _exit(2), fork(2), _Fork(3), unshare(2),
> + wait(2)
>
> Linux man‐pages (unreleased) (date) vfork(2)
> --- e480a82ad75a^:man/man7/signal-safety.7
> +++ e480a82ad75a:man/man7/signal-safety.7
> @@ -92,7 +92,7 @@
> fdatasync(2)
> fexecve(3) Added in POSIX.1‐2008
> ffs(3) Added in POSIX.1‐2008 TC2
> - fork(2) See notes below
> + _Fork(3)
> fstat(2)
> fstatat(2) Added in POSIX.1‐2008
> fsync(2)
> @@ -260,13 +260,6 @@
> siglongjmp(3) and the program subsequently calls an unsafe
> function, then the behavior of the program is undefined.
>
> - • POSIX.1‐2001 TC1 clarified that if an application calls fork(2)
> - from a signal handler and any of the fork handlers registered
> - by pthread_atfork(3) calls a function that is not async‐signal‐
> - safe, the behavior is undefined. A future revision of the
> - standard is likely to remove fork(2) from the list of async‐
> - signal‐safe functions.
> -
> • Asynchronous signal handlers that call functions which are can‐
> celation points and nest over regions of deferred cancelation
> may trigger cancelation whose behavior is as if asynchronous
>
>
> This is pushed in the posix24 branch, where I'm still working on the
> updates for POSIX.1-2024 (so if you find anything you'd like to amend,
> we're still in time).
>
> <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/log/?h=posix24>
i stumbled across https://sortix.org/blog/posix-2024/ last week, which
helped me spot a few things i'd missed cleaning up in the bionic
headers (despite having gone through the opengroup doc manually
already). in particular, various things (such as accept4()) that used
to be hidden behind _GNU_SOURCE that are now posix.
> >
> > /**
> > * _Fork() creates a new process. _Fork() differs from fork() in that it does
> > * not run any handlers set by pthread_atfork().
> > *
> > * Returns 0 in the child, the pid of the child in the parent,
> > * and returns -1 and sets `errno` on failure.
> > *
> > * Available since API level 35.
> > */
> > pid_t _Fork(void) __INTRODUCED_IN(35);
> >
> > looks like glibc has a bit more:
> >
> > https://www.gnu.org/software/libc/manual/html_node/Creating-a-Process.html
> >
> > The _Fork function is similar to fork, but it does not invoke any
> > callbacks registered with pthread_atfork, nor does it reset any
> > internal state or locks (such as the malloc locks). In the new
> > subprocess, only async-signal-safe functions may be called, such as
> > dup2 or execve.
> >
> > The _Fork function is an async-signal-safe replacement of fork. It
> > is a GNU extension.
> >
> > whereas i assumed that everyone knows that bionic's internal state
> > resetting is done via pthread_atfork() which, in retrospect, is
> > probably an unreasonable assumption /facepalm
> >
> > annoyingly, while this is slated for POSIX issue 8
> > (https://austingroupbugs.net/view.php?id=62) it's not there yet, so
> > there's nothing public to point to there.
>
> POSIX.1-2024 is out now, and our manual page will be there soon. :-)
>
>
> Have a lovely day!
> Alex
> >
> > > Have a lovely night!
> > > Alex
> > >
> > > --
> > > <https://www.alejandro-colomar.es/>
> > > Looking for a remote C programming job at the moment.
>
> --
> <https://www.alejandro-colomar.es/>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-27 13:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-29 22:12 _Fork() enh
2024-02-29 22:49 ` _Fork() Alejandro Colomar
2024-02-29 23:14 ` _Fork() enh
2025-05-24 18:46 ` _Fork() Alejandro Colomar
2025-05-27 13:48 ` _Fork() enh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).