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