[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#742965: libc0.1: openpty()/forkpty() fail on kfreebsd >=9.0



On Wed, Apr 02, 2014 at 09:45:23AM +0200, Petr Salinger wrote:
> The problem is not the handler for SIGCHLD, but it's content.

Yeah, same happens with SA_NOCLDWAIT, it's about whether the child gets
reaped.

> I doubt that the testcase worked under previous kernels.

My bad, I did not test this particular testcase but a larger body of code,
with tons of different pty code paths (handling IRIX, old SunOS and such)
on different Debian releases, it probably did something else.  The small
test case behaves the same on 8.x and 9.x.  Sorry for undertesting.

> The openpty() uses internally fork and waitpid.
> The waitpid in the testcase signal handler eats result needed by
> openpty implementation.

The offending code is in grantpt(), which openpty() calls.

I wonder how to fix it.  Merely documenting the restriction isn't really an
option, as no widespread system has it.  Saving the signal handler,
disabling it then restoring would work but introduces a slight race
condition (a child process can exit while we're in grantpt()).

It's interesting what real FreeBSD does.  Apparently, grantpt() is a no-op
there:

http://svnweb.freebsd.org/base/head/lib/libc/stdlib/ptsname.c?view=markup

but blindly commenting out the calls to grantpt()+unlockpt() doesn't seem
work to for us.


Meow!
-- 
A tit a day keeps the vet away.


Reply to: