forkfd: fix build with FreeBSD 14.2: convertForkfdWaitFlagsToWaitFlags()

The FreeBSD-specific pdfork() code in forkfd_freebsd.c code was failing
to build because convertForkfdWaitFlagsToWaitFlags() wasn't
defined. That function is behind a check for #ifdef HAVE_WAITID, which
is only defined if _POSIX_VERSION is 2008 or later. That macro has been
stuck at 2001 for the past 23 years. I can't explain how this code
compiled with FreeBSD 14.1 and earlier, because I am sure it was using
pdfork().

So just #define HAVE_WAITID for FreeBSD. It must have been there since
much earlier than 13.0, but that seems like a reasonable starting point
today.

We also need to #include <sys/param.h> to have the __FreeBSD_version__
macro, something that also wasn't needed in earlier versions. It was
probably indirectly #include'd by something.

Pick-to: 6.8
Change-Id: I262d9922128d046221b7fffd0ec481bc0012f55c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
(cherry picked from commit 729a6f56d08e3440f18704c1cf0b5672c0b90419)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2025-03-18 00:33:29 +00:00 committed by Qt Cherry-pick Bot
parent 7de18b1467
commit db33112d4d
2 changed files with 6 additions and 1 deletions

View File

@ -35,7 +35,7 @@
//#define FORKFD_DISABLE_FORK_FALLBACK 1 /* disable falling back to fork() from system_forkfd() */
#include <sys/types.h>
#if defined(__OpenBSD__) || defined(__NetBSD__)
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
# include <sys/param.h>
#endif
#include <sys/time.h>
@ -75,6 +75,7 @@
#if (defined(__FreeBSD__) && defined(__FreeBSD_version) && __FreeBSD_version >= 1300000)
# include <sys/eventfd.h>
# define HAVE_EVENTFD 1
# define HAVE_WAITID 1
#endif
#if (defined(__FreeBSD__) && defined(__FreeBSD_version) && __FreeBSD_version >= 1000032) || \
(defined(__OpenBSD__) && OpenBSD >= 201505) || \

View File

@ -31,6 +31,10 @@
#undef SYSTEM_FORKFD_CAN_VFORK
#ifndef HAVE_WAITID
# error Need waitid() API
#endif
// in forkfd.c
static int convertForkfdWaitFlagsToWaitFlags(int ffdoptions);
static void convertStatusToForkfdInfo(int status, struct forkfd_info *info);