2011-01-13 Ulrich Drepper <drepper@gmail.com>
+ * sysdeps/posix/spawni.c (__spawni): Don't fail if close file action
+ in child fails because the descriptor is already closed.
+
[BZ #12397]
* sysdeps/unix/sysv/linux/mkdirat.c (mkdirat): Fix handling of missing
syscall.
/* Guts of POSIX spawn interface. Generic POSIX.1 version.
- Copyright (C) 2000-2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2000-2005, 2006, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/resource.h>
#include "spawn_int.h"
#include <not-cancel.h>
#include <local-setxid.h>
if (file_actions != NULL)
{
int cnt;
+ struct rlimit64 fdlimit;
+ bool have_fdlimit = false;
for (cnt = 0; cnt < file_actions->__used; ++cnt)
{
{
case spawn_do_close:
if (close_not_cancel (action->action.close_action.fd) != 0)
- /* Signal the error. */
- _exit (SPAWN_ERROR);
+ {
+ if (! have_fdlimit)
+ {
+ getrlimit64 (RLIMIT_NOFILE, &fdlimit);
+ have_fdlimit = true;
+ }
+
+ /* Only signal errors for file descriptors out of range. */
+ if (action->action.close_action.fd < 0
+ || action->action.close_action.fd >= fdlimit.rlim_cur)
+ /* Signal the error. */
+ _exit (SPAWN_ERROR);
+ }
break;
case spawn_do_open: