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

2014-04-04 Thread Petr Salinger
I wonder how to fix it.  Merely documenting the restriction isn't really 
anoption, 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()).


In fact, it is documented:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/grantpt.html

  The behavior of the grantpt() function is unspecified if the application
  has installed a signal handler to catch SIGCHLD signals.

What is the real package, which hits this problem ?

Petr


--
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/alpine.lnx.2.00.1404040929190.25...@contest.felk.cvut.cz



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

2014-04-03 Thread Adam Borowski
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.


-- 
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20140403140650.ga12...@angband.pl



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

2014-04-02 Thread Petr Salinger

Hi.

I doubt that the testcase worked under previous kernels.
The problem is not the handler for SIGCHLD, but it's content.

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

Petr


--
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/alpine.lnx.2.00.1404020934590.2...@contest.felk.cvut.cz



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

2014-03-29 Thread Adam Borowski
Package: libc0.1
Version: 2.18-4
Severity: normal


If a process has a handler for SIGCHLD, openpty() fails on kfreebsd with 9.x
kernels.  It worked ok on 8.x, and works on real (ie, no glibc) FreeBSD.

A reduced test case attached; when commenting out the sigaction line,
openpty() starts working again.


-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 9.2-1-amd64
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libc0.1 depends on:
ii  libgcc1  1:4.8.2-16

libc0.1 recommends no packages.

Versions of packages libc0.1 suggests:
ii  debconf [debconf-2.0]  1.5.52
pn  glibc-doc  none
ii  locales2.18-4

-- debconf information:
  glibc/upgrade: true
  glibc/disable-screensaver:
  glibc/restart-services:
  glibc/restart-failed:
  libraries/restart-without-asking: false
// Link with -lutil
#include stdio.h
#include pty.h
#include string.h
#include errno.h
#include sys/types.h
#include sys/wait.h
#include signal.h

static void sigchild(int dummy)
{
while (waitpid(-1,0,WNOHANG)0);
}

int main()
{
int master, slave;

struct sigaction act;
sigemptyset(act.sa_mask);
act.sa_flags=SA_RESTART;
act.sa_handler=sigchild;
sigaction(SIGCHLD,act,0);

if (openpty(master, slave, 0, 0, 0))
{
printf(Failed: %s\n, strerror(errno));
return 1;
}
printf(Ok!\n);
return 0;
}