[Konsole-devel] [Bug 42986] chownpty failed for /dev/ptyp0::/dev/ttypp0 in KDE-3.0

Adriaan De Groot adridg at cs.kun.nl
Mon Feb 17 14:26:45 UTC 2003


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
     
http://bugs.kde.org/show_bug.cgi?id=42986     




------- Additional Comments From adridg at cs.kun.nl  2003-02-17 15:26 -------
O yeah, now I remember what goes on. I fixed this problem, mostly, a while back. And 
promptly lost the patch. 
 
The problem stems from the fact that FBSD processes have plenty of FDs open. So 
while 0,1,2 are stdin, stdout, stderr, as on Linux, FBSD KDE processes also have 3...12 
(or so) open for all the pipes and streams and whatnot that they use.  For example, my 
klipper has 
 
adridg   kdeinit      198    3* pipe cb24d0e0 <-> cb24d040      0 rw 
 
Apparently dup2()ing to 3 fails. (Strangely, this is a pipe to .. klipper. But FD 5, for 
example, is the DCOP stream.) So just changing the FILENO define to something else 
may work, but can just as easily break if the infrastructure fails. In addition, just making 
it a big number N runs the risk of having someone open gobs of konsole windows in 
one process and running into that number, dup2()ing onto itself and then having FD N 
stomped on with the next opened konsole window. 
 
I think the right way to deal with this is to let go of FILENO as a constant and make it a 
variable initialized at runtime by open()in /dev/null and using the returned FD as 
grantyprt control FD. This adds the complication that now you have to pass the control 
FD to grantpty, but that's not that hard.



More information about the konsole-devel mailing list