When fork() inside forkpty() fails with an error, forkpty() leaves two open file handles. The handles are not stored anywhere and are not closed.
Created attachment 1920 [details] patch to close file descriptors on fork() error
Subject: Bug 4813 CVSROOT: /cvs/glibc Module name: libc Changes by: jakub@sourceware.org 2007-07-20 07:20:07 Modified files: . : ChangeLog login : forkpty.c Log message: [BZ #4813] * login/forkpty.c (forkpty): Close master and slave fds on fork failure. Patch by Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/libc/ChangeLog.diff?cvsroot=glibc&r1=1.10709&r2=1.10710 http://sourceware.org/cgi-bin/cvsweb.cgi/libc/login/forkpty.c.diff?cvsroot=glibc&r1=1.2&r2=1.3
Fixed in CVS.