[Konsole-devel] Bug#42986: dup2() in freebsd
Michael Samuel
michael at miknet.net
Fri Aug 30 06:07:28 UTC 2002
Ok, I figured it out.
The dup2() it's using is from libc_r, which is the thread library on
FreeBSD.
In the libc_r wrapper, there's this code:
/* Check if the file descriptor is out of range: */
if (newfd < 0 || newfd >= _thread_dtablesize ||
newfd == _thread_kern_pipe[0] || newfd == _thread_kern_pipe[1]) {
/* Return a bad file descriptor error: */
errno = EBADF;
ret = -1;
}
Any guesses what numbers are in _thread_kern_pipe[0] and
_thread_kern_pipe[1] (which are setup shortly after setting up stdin,
stdout and stderr)?
So, when I changed PTY_FILENO to 15, it now works :)
Of course, that doesn't fix the race condition still present on all
systems. (what happens if somebody opens the tty device before we do the
chown, but after we open the pty master?)
--
Michael Samuel <michael at miknet.net>
(Complete bug history is available at http://bugs.kde.org/db/42/42986.html)
More information about the konsole-devel
mailing list