Date: Sat, 21 Sep 1996 09:12:23 +1000 (EST) From: John Birrell <jb@cimlogic.com.au> To: hsu@freefall.freebsd.org (Jeffrey Hsu) Cc: hackers@FreeBSD.org, jb@cimlogic.com.au Subject: Re: libc_r bug Message-ID: <199609202312.JAA14006@freebsd3.cimlogic.com.au> In-Reply-To: <199609202133.OAA05442@freefall.freebsd.org> from Jeffrey Hsu at "Sep 20, 96 02:33:28 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
> > 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,
The workaround is "the fix" (provided that the calls to _thread_fd_table_init
are _after_ the initialisation loop). _thread_fd_table_init() just sets up
the table for a fd. fds 0, 1 and 2 don't have to be valid.
> 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;
>
Leave the loop starting at i = 0 so that _thread_fd_table_init(0) etc
can check if memory has been allocated, then put the _thread_fd_table_init
calls after the loop.
Regards,
--
John Birrell CIMlogic Pty Ltd
jb@cimlogic.com.au 119 Cecil Street
Ph +61 3 9690 6900 South Melbourne Vic 3205
Fax +61 3 9690 6650 Australia
Mob +61 18 353 137
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609202312.JAA14006>
