kfish / xsel

A command-line program for getting and setting the contents of the X selection

Home Page:http://www.kfish.org/software/xsel/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ryandesign opened this issue · 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.

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+?