[PATCH v2] posix: Handle negative fds in spawn's addfchdir
Collin Funk
collin.funk1@gmail.com
Thu Mar 26 20:35:08 GMT 2026
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
More information about the Libc-alpha
mailing list