Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Sep 1996 13:24:54 +1000 (EST)
From:      John Birrell <jb@cimlogic.com.au>
To:        hsu@freefall.freebsd.org (Jeffrey Hsu)
Cc:        jb@cimlogic.com.au, hackers@freefall.freebsd.org
Subject:   Re: libc_r bug
Message-ID:  <199609210324.NAA14305@freebsd3.cimlogic.com.au>
In-Reply-To: <199609210228.TAA13995@freefall.freebsd.org> from Jeffrey Hsu at "Sep 20, 96 07:28:31 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> That takes care of fd 0, 1, and 2.  But how do you tell if the parent
> process has set up another fd, say, 3, for use by the child?

Hmmm. You can't tell. This means that write will have to call
_thread_fd_table_init in case the fd hasn't been used yet.

There are some traps associated with sharing open file descriptors between
processes, particularly between threaded and non-threaded processes because
of the need for the threaded process to change the file descriptor to
non-blocking. The most common place where this occurs is between the
shell and a threaded process. If the shell uses the file descriptor
before the child process has _completely_ exited (and set the file
descriptors back to blocking) it needs to be able to handle EAGAIN
errors. pdksh is much better than sh because it checks for fd = 0 set
to non-blocking and restores the blocking state. I think all these issues
would go away if kernel threads were used (and to me, this is the best
justification for kernel threads). For the time being, though, the handling
of blocking/non-blocking file descriptors is a compromize.

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?199609210324.NAA14305>