Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ryandesign opened this issue Nov 2, 2021 · 1 comment
Open

Comments

@ryandesign
Copy link

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.

@derekschrock
Copy link

derekschrock commented Nov 5, 2021

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 added a commit to derekschrock/macports-ports that referenced this issue Nov 21, 2021
* disable check for autoconf AC_FUNC_FORK vfork checking caching to yes.
* AC_FUNC_FORK will create a `#define vfork fork` macro in config.h
* vfork has been mark depercated in macOS 12.
* This macro will mark fork() usage as depercated due to
  config.h being included before system header <unistd.h>.

Re: kfish/xsel#42
Closes: https://trac.macports.org/ticket/63748
ra1nb0w pushed a commit to macports/macports-ports that referenced this issue Dec 4, 2021
* disable check for autoconf AC_FUNC_FORK vfork checking caching to yes.
* AC_FUNC_FORK will create a `#define vfork fork` macro in config.h
* vfork has been mark depercated in macOS 12.
* This macro will mark fork() usage as depercated due to
  config.h being included before system header <unistd.h>.

Re: kfish/xsel#42
Closes: https://trac.macports.org/ticket/63748
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants