github-gist icon indicating copy to clipboard operation
github-gist copied to clipboard

xsel.c:372:14: error: 'fork' is deprecated: Use posix_spawn or fork

Open ryandesign opened this issue 3 years ago • 1 comments

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.

ryandesign avatar Nov 02 '21 12:11 ryandesign

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 from configure.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+?

derekschrock avatar Nov 05 '21 02:11 derekschrock