diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index 20f2c16c8fd6..58044b3a64fa 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -163,11 +163,8 @@ process_file_actions_entry(posix_spawn_file_actions_entry_t *fae) return (errno); break; case FAE_CLOSE: - /* Perform a close() */ - if (_close(fae->fae_fildes) != 0) { - if (errno == EBADF) - return (EBADF); - } + /* Perform a close(), do not fail if already closed */ + (void)_close(fae->fae_fildes); break; } return (0);