10 #include "not-cancel.h"
11 #include "pty-private.h"
14 /* Close all file descriptors except the one specified. */
18 DIR *dir
= __opendir ("/proc/self/fd");
22 while ((d
= __readdir64 (dir
)) != NULL
)
23 if (isdigit (d
->d_name
[0]))
26 long int fd
= strtol (d
->d_name
, &endp
, 10);
27 if (*endp
== '\0' && fd
!= PTY_FILENO
&& fd
!= dirfd (dir
))
28 close_not_cancel_no_status (fd
);
33 int nullfd
= open_not_cancel_2 (_PATH_DEVNULL
, O_RDONLY
);
34 assert (nullfd
== STDIN_FILENO
);
35 nullfd
= open_not_cancel_2 (_PATH_DEVNULL
, O_WRONLY
);
36 assert (nullfd
== STDOUT_FILENO
);
37 __dup2 (STDOUT_FILENO
, STDERR_FILENO
);
40 #define CLOSE_ALL_FDS() close_all_fds()
42 #include <sysdeps/unix/grantpt.c>