Skip to content

Commit

Permalink
contain: fail of fcntl(F_GETFD) fails for a fd with something else th…
Browse files Browse the repository at this point in the history
…en EBADFD
  • Loading branch information
robertswiecki committed Sep 30, 2023
1 parent f388cad commit c151545
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion contain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,13 @@ static bool containMakeFdsCOENaive(nsjconf_t* nsjconf) {
*/
for (unsigned fd = 0; fd < 1024; fd++) {
int flags = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD, 0));
if (flags == -1) {
if (flags == -1 && errno == EBADF) {
continue;
}
if (flags == -1) {
PLOG_E("Couldn't get flags for fd=%d", fd)
return false;
}
if (containPassFd(nsjconf, fd)) {
LOG_D("fd=%d will be passed to the child process", fd);
if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, flags & ~(FD_CLOEXEC))) == -1) {
Expand Down

0 comments on commit c151545

Please sign in to comment.