--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: libc0.1: openpty()/forkpty() fail on kfreebsd >=9.0
- From: Adam Borowski <kilobyte@angband.pl>
- Date: Sat, 29 Mar 2014 16:06:43 +0100
- Message-id: <20140329150643.19674.58869.reportbug@localhost>
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 locales 2.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;
}
--- End Message ---
--- Begin Message ---
- To: 742965-done@bugs.debian.org
- Cc: Adam Borowski <kilobyte@angband.pl>
- Subject: Re: Bug#742965: libc0.1: openpty()/forkpty() fail on kfreebsd >=9.0
- From: Aurelien Jarno <aurelien@aurel32.net>
- Date: Thu, 17 Dec 2015 19:47:05 +0100
- Message-id: <20151217184705.GA9943@aurel32.net>
- In-reply-to: <alpine.LNX.2.00.1404040929190.25996@contest.felk.cvut.cz>
- References: <alpine.LNX.2.00.1404020934590.2102@contest.felk.cvut.cz> <alpine.LNX.2.00.1404040929190.25996@contest.felk.cvut.cz>
On 2014-04-04 09:35, Petr Salinger wrote:
> >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.
Indeed this is a possible behaviour of this function. The same will
happen on a GNU/Linux system if /dev/pts is mounted with the wrong
permissions.
I am therefore closing this bug.
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://www.aurel32.net
--- End Message ---