tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] Add posix_spawn_file_actions_addclosefrom_np



Chris Hanson <cmhanson%eschatologist.net@localhost> writes:

> On Jun 29, 2026, at 2:12 AM, Martin Husemann <martin%netbsd.org@localhost> wrote:
>> 
>> One minor nit: making this visible (in include/spawn.h) only #ifdef _NETBSD_SOURCE
>> might not be a good idea. I think it should be visible by default unless
>> some stricte standard is requested.
>
> I wasn’t sure what the rule would be on “NetBSD-only” additions to POSIX-standardized bits. (Even though it’s not really NetBSD-only, and is present on Solaris and Linux and FreeBSD etc.)
>
> Isn’t most everything on NetBSD built with _NETBSD_SOURCE set unless specifically built otherwise? (E.g. with POSIX-conformance flags set.)

Visibility defines are tricky business.

See sys/featuretest.h.    Basically, if you define _XOPEN_SOURCE or some
such, then the program should only see things required by that standard.
If you don't define any of those, then _NETBSD_SOURCE is assumed.

So it is correct to guard this on _NETBSD_SOURCE, so that it is withheld
if _XOPEN_SOURCE or _POSIX_SOURCE is defined.  However, a program with
no visibility defines that uses it should succeed in compiling.

Chris: If you build a test program with no visibility defines that uses
this API, does it build?



What is trouble is e.g. programs that use someting in XOPEN, and that is
hidden by default on some Other OS (often GNU/Linux).  The author then
sets an _XOPEN_SOURCE define.  That would be ok if the program were
strictly written to that XOPEN API.  But usually it isn't, and it wants
to use APIs beyond XOPEN.  And then on Linux, it defines some other
define to bring those things back.  And then we in pkgsrc have to add
_NETBSD_SOURCE to being them back too.

The right thing IMHO is that upstream should have only set _XOPEN_SOURCE
on platforms that hide normal things by default.   So far that's just
Linux and maybe occasionally solaris, but I basically remember Linux
from having to fix things.


Home | Main Index | Thread Index | Old Index