xsel
xsel copied to clipboard
xsel.c:372:14: error: 'fork' is deprecated: Use posix_spawn or fork
xsel 1.2.0 does not build on macOS Monterey. The error is:
xsel.c:372:14: error: 'fork' is deprecated: Use posix_spawn or fork [-Werror,-Wdeprecated-declarations]
if ((pid = fork()) == -1) {
^
This was reported to MacPorts here.
This seems to be with the macro generated by autoconf in config.h?
#define vfork fork
This is renaming vfork
in <unistd.h>
to fork
hence the odd message deprecation message: fork is deprecated... use posix_spawn or fork
So it seems that there's a number of options?
- Remove
AC_FUNC_FORK
fromconfigure.ac
-
#undef vfork
if you're macOS 12+ before#include <unistd.h>
- Define
_POSIX_C_SOURCE
before<unistd.h>.
200112L` seems to work here. - Put the
config.h
include after the system headers. Don't that's right since autoconf is trying to "fix things" - Or is this an autoconf bug? Should autoconf not create a
#define vfork fork
macro if it's macOS 12+?