[PATCH v2] posix: Handle negative fds in spawn's addfchdir
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Thu Mar 26 20:45:33 GMT 2026
On 26/03/26 17:35, Collin Funk wrote:
> Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:
>
>> On 26/03/26 05:23, Lucas Chollet wrote:
>>> This patch makes `posix_spawn_file_actions_addfchdir` return EBADF on
>>> negative file descriptors. This is mandated by POSIX.
>>>
>>> Signed-off-by: Lucas Chollet <lucas.chollet@free.fr>
>>
>> I think we should remove __spawn_valid_fd and make the fd description
>> handling consistent on all posix_spawn routines (posix_spawn_file_actions_addclose,
>> posix_spawn_file_actions_addclosefrom, posix_spawn_file_actions_adddup2,
>> posix_spawn_file_actions_addopen, posix_spawn_file_actions_addtcsetpgrp_np,
>> and posix_spawn_file_actions_addfchdir_np).
>>
>> This will also need to adjust posix/tst-posix_spawn-fd that expects
>> that expets sysconf (_SC_OPEN_MAX) to fail.
>
> I agree that removing __spawn_valid_fd is probably the correct decision.
> However, I think we should wait for POSIX to clear up the contradictory
> text. I opened a bug there [1].
>
> Collin
>
> [1] https://austingroupbugs.net/view.php?id=1977
>
Sounds reasonable, although musl and *BSD already follows your suggestion.
More information about the Libc-alpha
mailing list