[PATCH v2 4/4] posix: Add posix_spawn_file_actions_closefrom

Adhemerval Zanella adhemerval.zanella@linaro.org
Wed Dec 23 16:18:44 GMT 2020



On 23/12/2020 11:27, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> +* The posix_spawn_file_actions_closefrom_np has been added, enabling
>> +  posix_spawn and posix_spawnp to close all file descriptors greater than
>> +  a giver integer.  This function is a GNU extension, although Solaris also
>> +  provides a similar function.
> 
> “The function posix_spawn_file_actions_closefrom_np”?

Ack.

> 
>> +static void
>> +do_test_closefrom (void)
>> +{
>> +  int lowfd = xopen ("/dev/null", O_WRONLY, 0);
>> +  for (int i = 1; i < NFDS; i++)
>> +    xopen ("/dev/null", O_WRONLY, 0);
> 
> The usual observation about NFDS and fgap checking.

Ack.

> 
>> +  /* Create some gaps, close up to a threshold, and check result.  */
>> +  xclose (57);
>> +  xclose (78);
>> +  xclose (81);
>> +  xclose (82);
>> +  xclose (84);
>> +  xclose (90);
> 
> Please add lowfd here as well.

Ack.

> 
>> diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
>> index f157bfffd2..c337c7a6a1 100644
>> --- a/sysdeps/unix/sysv/linux/spawni.c
>> +++ b/sysdeps/unix/sysv/linux/spawni.c
>> @@ -16,22 +16,17 @@
>>     License along with the GNU C Library; if not, see
>>     <https://www.gnu.org/licenses/>.  */
>>  
>> -#include <spawn.h>
>> -#include <fcntl.h>
>> -#include <paths.h>
>> -#include <string.h>
>> -#include <sys/resource.h>
>> -#include <sys/wait.h>
>> -#include <sys/param.h>
>> -#include <sys/mman.h>
>> -#include <not-cancel.h>
>> +#include <arch-fd_to_filename.h>
>> +#include <internal-signals.h>
>> +#include <ldsodefs.h>
>>  #include <local-setxid.h>
>> +#include <not-cancel.h>
>> +#include <paths.h>
>>  #include <shlib-compat.h>
>> -#include <nptl/pthreadP.h>
>> -#include <dl-sysdep.h>
>> -#include <libc-pointer-arith.h>
>> -#include <ldsodefs.h>
>> -#include "spawn_int.h"
>> +#include <spawn.h>
>> +#include <spawn_int.h>
>> +#include <sysdep.h>
>> +#include <sys/resource.h>
> 
> Is <arch-fd_to_filename.h> really required here?
> 

Indeed.


More information about the Libc-alpha mailing list