@@ -1422,7 +1422,7 @@ kern_close(struct thread *td, int fd)
1422
1422
}
1423
1423
1424
1424
static int
1425
- close_range_cloexec (struct thread * td , u_int lowfd , u_int highfd )
1425
+ close_range_flags (struct thread * td , u_int lowfd , u_int highfd , int flags )
1426
1426
{
1427
1427
struct filedesc * fdp ;
1428
1428
struct fdescenttbl * fdt ;
@@ -1439,8 +1439,12 @@ close_range_cloexec(struct thread *td, u_int lowfd, u_int highfd)
1439
1439
}
1440
1440
for (; fd <= highfd ; fd ++ ) {
1441
1441
fde = & fdt -> fdt_ofiles [fd ];
1442
- if (fde -> fde_file != NULL )
1443
- fde -> fde_flags |= UF_EXCLOSE ;
1442
+ if (fde -> fde_file != NULL ) {
1443
+ if ((flags & CLOSE_RANGE_CLOEXEC ) != 0 )
1444
+ fde -> fde_flags |= UF_EXCLOSE ;
1445
+ if ((flags & CLOSE_RANGE_CLOFORK ) != 0 )
1446
+ fde -> fde_flags |= UF_FOCLOSE ;
1447
+ }
1444
1448
}
1445
1449
out_locked :
1446
1450
FILEDESC_XUNLOCK (fdp );
@@ -1498,8 +1502,8 @@ kern_close_range(struct thread *td, int flags, u_int lowfd, u_int highfd)
1498
1502
return (EINVAL );
1499
1503
}
1500
1504
1501
- if ((flags & CLOSE_RANGE_CLOEXEC ) != 0 )
1502
- return (close_range_cloexec (td , lowfd , highfd ));
1505
+ if ((flags & ( CLOSE_RANGE_CLOEXEC | CLOSE_RANGE_CLOFORK ) ) != 0 )
1506
+ return (close_range_flags (td , lowfd , highfd , flags ));
1503
1507
1504
1508
return (close_range_impl (td , lowfd , highfd ));
1505
1509
}
@@ -1519,7 +1523,7 @@ sys_close_range(struct thread *td, struct close_range_args *uap)
1519
1523
AUDIT_ARG_CMD (uap -> highfd );
1520
1524
AUDIT_ARG_FFLAGS (uap -> flags );
1521
1525
1522
- if ((uap -> flags & ~(CLOSE_RANGE_CLOEXEC )) != 0 )
1526
+ if ((uap -> flags & ~(CLOSE_RANGE_CLOEXEC | CLOSE_RANGE_CLOFORK )) != 0 )
1523
1527
return (EINVAL );
1524
1528
return (kern_close_range (td , uap -> flags , uap -> lowfd , uap -> highfd ));
1525
1529
}
0 commit comments