[Toybox] vfork() deprecated on macOS

enh enh at google.com
Wed May 11 13:20:50 PDT 2022


the toybox build is pretty noisy on a current mac, complaining that
vfork() should be replaced by fork() or posix_spawn().

looks like it's because they've changed vfork() to just be fork() and
would like people to accept that they understand that by changing
their source to say fork() instead... (i'll copy & paste the man page
here because afaik apple doesn't give us anywhere to link to...)

     The vfork system call can be used to create new processes. As of macOS
     12.0, this system call behaves identically to the fork(2) system call,
     except without calling any handlers registered with pthread_atfork(2).

     This system call is deprecated. In a future release, it may begin to return
     errors in all cases, or may be removed entirely.  It is extremely strongly
     recommended to replace all uses with fork(2) or, ideally, posix_spawn(3).

weirdly it looks like you can use _POSIX_C_SOURCE to make this go
away? from their unistd.h:

#if !defined(_POSIX_C_SOURCE)
__deprecated_msg("Use posix_spawn or fork")
#endif
pid_t    vfork(void) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;

-Wno-deprecated-declarations in configure works too, though their
threat to make vfork() always fail in a future release makes me
question whether that's such a good idea. (i haven't followed apple
closely enough to know whether there's any precedent for violent
breakage like that. i'm not sure why you wouldn't just remove the
symbol rather than replace it with an implementation that always
fails?)



More information about the Toybox mailing list