summaryrefslogtreecommitdiffstats
path: root/lib/libc_r/uthread/uthread_init.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>1999-08-05 12:08:10 +0000
committerdeischen <deischen@FreeBSD.org>1999-08-05 12:08:10 +0000
commit9161b0a7904cd5f5ec64dfebc31201ccdf41c2f9 (patch)
treefded8c38645f1509bdaf35c512fd84076a5ce350 /lib/libc_r/uthread/uthread_init.c
parent4df48d07f1726a1f451ba70d0bcdd288e3c2803a (diff)
downloadFreeBSD-src-9161b0a7904cd5f5ec64dfebc31201ccdf41c2f9.zip
FreeBSD-src-9161b0a7904cd5f5ec64dfebc31201ccdf41c2f9.tar.gz
Fix thread initialization to allow for the case where stdio file
descriptors are not opened. PR: bin/12853 Reviewed by: jb
Diffstat (limited to 'lib/libc_r/uthread/uthread_init.c')
-rw-r--r--lib/libc_r/uthread/uthread_init.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/libc_r/uthread/uthread_init.c b/lib/libc_r/uthread/uthread_init.c
index 90a91cc..c80427a 100644
--- a/lib/libc_r/uthread/uthread_init.c
+++ b/lib/libc_r/uthread/uthread_init.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: uthread_init.c,v 1.15 1999/07/11 05:56:37 jasone Exp $
+ * $Id: uthread_init.c,v 1.16 1999/07/12 16:09:30 dt Exp $
*/
/* Allocate space for global thread variables here: */
@@ -124,8 +124,9 @@ _thread_init(void)
/* 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");
/*
@@ -282,6 +283,9 @@ _thread_init(void)
}
/* Allocate memory for the file descriptor table: */
if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) {
+ /* Avoid accesses to file descriptor table on exit: */
+ _thread_dtablesize = 0;
+
/*
* Cannot allocate memory for the file descriptor
* table, so abort this process.
@@ -306,11 +310,11 @@ _thread_init(void)
}
/* 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");
+ for (i = 0; i < 3; i++) {
+ if ((_thread_fd_table_init(i) != 0) &&
+ (errno != EBADF))
+ PANIC("Cannot initialize stdio file "
+ "descriptor table entry");
}
}
}
OpenPOWER on IntegriCloud