| Summary: | Re: resend: uthread_init.c PANICs in case of (legally) close stdin | ||
|---|---|---|---|
| Product: | Base System | Reporter: | eischen <eischen> |
| Component: | bin | Assignee: | GNATS administrator <gnats-admin> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | CC: | eischen |
| Priority: | Normal | ||
| Version: | 1.0-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->closed Mis-filed en route to PR 12853. |
Wow, this CC: list is growing! Can you please try this more complete patch (made against -stable)? I believe it better handles initialization of the fd tables for fds < 3. Index: uthread_fd.c =================================================================== RCS file: /A/cvs/src/lib/libc_r/uthread/uthread_fd.c,v retrieving revision 1.9.2.2 diff -u -r1.9.2.2 uthread_fd.c --- uthread_fd.c 1999/07/23 13:00:27 1.9.2.2 +++ uthread_fd.c 1999/07/28 16:31:33 @@ -94,13 +94,13 @@ TAILQ_INIT(&entry->w_queue); /* Get the flags for the file: */ - if (fd >= 3 && (entry->flags = - _thread_sys_fcntl(fd, F_GETFL, 0)) == -1) { + if (((fd >= 3) || (_pthread_stdio_flags[fd] == -1)) && + (entry->flags = _thread_sys_fcntl(fd, F_GETFL, 0)) == -1) { ret = -1; - } + } else { /* Check if a stdio descriptor: */ - if (fd < 3) + if ((fd < 3) && (_pthread_stdio_flags[fd] != -1)) /* * Use the stdio flags read by * _pthread_init() to avoid Index: uthread_init.c =================================================================== RCS file: /A/cvs/src/lib/libc_r/uthread/uthread_init.c,v retrieving revision 1.9.2.3 diff -u -r1.9.2.3 uthread_init.c --- uthread_init.c 1999/07/23 13:00:29 1.9.2.3 +++ uthread_init.c 1999/07/28 16:43:27 @@ -121,8 +121,9 @@ /* Get the standard I/O flags before messing with them : */ for (i = 0; i < 3; i++) - if ((_pthread_stdio_flags[i] = - _thread_sys_fcntl(i,F_GETFL, NULL)) == -1) + if (((_pthread_stdio_flags[i] = + _thread_sys_fcntl(i,F_GETFL, NULL)) == -1) && + (errno != EBADF)) PANIC("Cannot get stdio flags"); /* @@ -292,12 +293,18 @@ } /* Initialize stdio file descriptor table entries: */ - if ((_thread_fd_table_init(0) != 0) || - (_thread_fd_table_init(1) != 0) || - (_thread_fd_table_init(2) != 0)) { - PANIC("Cannot initialize stdio file descriptor " - "table entries"); - } + if ((_thread_fd_table_init(0) != 0) && + (errno != EBADF)) + PANIC("Cannot initialize stdio file " + "descriptor table entries"); + else if ((_thread_fd_table_init(1) != 0) && + (errno != EBADF)) + PANIC("Cannot initialize stdout file " + "descriptor table entries"); + else if ((_thread_fd_table_init(2) != 0) && + (errno != EBADF)) + PANIC("Cannot initialize stderr file " + "descriptor table entries"); } } Dan Eischen eischen@vigrid.com