From owner-freebsd-hackers Fri Sep 20 14:33:31 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA05465 for hackers-outgoing; Fri, 20 Sep 1996 14:33:31 -0700 (PDT) Received: (from hsu@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA05442; Fri, 20 Sep 1996 14:33:28 -0700 (PDT) Date: Fri, 20 Sep 1996 14:33:28 -0700 (PDT) From: Jeffrey Hsu Message-Id: <199609202133.OAA05442@freefall.freebsd.org> To: dubois@primate.wisc.edu Subject: Re: libc_r bug Cc: hackers Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > What happens, and what do you expect to happen? The first write gets lost. This is because the uthreads internal fd table is not set up for fds which are inherited from the parent process. I got around it with the following hack. This workaround is bad because it assumes that fd 0, 1, and 2 are valid upon start-up, which is generally but universally true. Alternatively, one could place a call to _thread_fd_table_init() in uthreads_write.c. Neither solution is very stisfactory. *** uthread_init.c 1996/08/20 08:21:23 1.3 --- uthread_init.c 1996/09/20 18:18:53 *************** *** 176,186 **** */ PANIC("Cannot allocate memory for file descriptor table"); } else { /* * Enter a loop to initialise the file descriptor * table: */ ! for (i = 0; i < _thread_dtablesize; i++) { /* Initialise the file descriptor table: */ _thread_fd_table[i] = NULL; } --- 176,189 ---- */ PANIC("Cannot allocate memory for file descriptor table"); } else { + _thread_fd_table_init(0); + _thread_fd_table_init(1); + _thread_fd_table_init(2); /* * Enter a loop to initialise the file descriptor * table: */ ! for (i = 2; i < _thread_dtablesize; i++) { /* Initialise the file descriptor table: */ _thread_fd_table[i] = NULL;