Re: _Fork()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 29, 2024 at 2:49 PM Alejandro Colomar <alx@xxxxxxxxxx> 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.





[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux