From owner-freebsd-ports@FreeBSD.ORG Thu Oct 8 12:05:00 2009 Return-Path: Delivered-To: ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4851B106566B for ; Thu, 8 Oct 2009 12:05:00 +0000 (UTC) (envelope-from matthias.andree@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id A6C548FC14 for ; Thu, 8 Oct 2009 12:04:59 +0000 (UTC) Received: (qmail invoked by alias); 08 Oct 2009 11:38:18 -0000 Received: from balu.cs.uni-paderborn.de (EHLO balu.cs.uni-paderborn.de) [131.234.21.37] by mail.gmx.net (mp052) with SMTP; 08 Oct 2009 13:38:18 +0200 X-Authenticated: #428038 X-Provags-ID: V01U2FsdGVkX18s5sUzkXgs1kn1V15RtPinibvZExIFim3zF6dDLI z8kBmkFJzh52MY Received: from localhost ([127.0.0.1]) by balu.cs.uni-paderborn.de with esmtp (Exim 4.69) (envelope-from ) id KR71NT-000344-9T; Thu, 08 Oct 2009 13:38:17 +0200 Message-ID: <4ACDCF28.6040807@gmx.de> Date: Thu, 08 Oct 2009 13:38:16 +0200 From: Matthias Andree User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Stephen Hocking References: <6300771b0910071753s6580c099i8c348824a6fe1a72@mail.gmail.com> In-Reply-To: <6300771b0910071753s6580c099i8c348824a6fe1a72@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.54 Cc: ports@freebsd.org Subject: Re: sigwait - differences between Linux & FreeBSD X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Oct 2009 12:05:00 -0000 Stephen Hocking schrieb: > Hi all, > > In my efforts to make the xrdp port more robust under FreeBSD, I have > discovered that sigwait (kind of an analogue to select(2), but for > signals rather than I/O) re-enables ignored signals in its list under > Linux, but not FreeBSD. If the application relies on sigwait() to wait for and extract an ignored signal (SIG_IGN), it is non-portable, as it expects non-POSIX semantics, and should be fixed by the upstream maintainer (I haven't checked that). Note: Linux has the same semantics, quoting its manual page (on Ubuntu 9.10 beta): sigwait suspends the calling thread until one of the signals in set is delivered to the calling thread. It then stores the number of the sig‐ > nal received in the location pointed to by sig and returns. The signals > in set must be blocked and not ignored on entrance to sigwait. If the delivered signal has a signal handler function attached, that function is not called. > The sesman daemon uses SIGCHLD to clean up after a session has exited. Under > Linux this works OK, under FreeSBD it doesn't. Not sure I understand. How can it clean up if it's not made aware of child's termination? Or do some Linux kernels behave in another way? Setting SIGCHLD to SIG_IGN (default) means that the kernel will let go of the child processes as they exit, rather than turn them into zombies. You cannot wait() for them though. > I have worked around it in a very hackish manner (define a > dummy signal handler and enable it using signal, which means that the > sigwait call can then be unblocked by it), but am wondering if anyone > else has run across the same problem, and if so, if they fixed it in > an elegant manner. Also, does anyone know the correct semantics of > sigwait under this situation? That is not a hackish workaround, but one of the few safe ways to sigwait() for SIGCHLD. A version fixed thus should still work on Linux, so that fix should be made by xrdp upstream. The canonical reference would be the POSIX standard (IEEE Std 1003.1). 2008: http://www.opengroup.org/onlinepubs/9699919799/ 2001, 2004 edition: http://www.opengroup.org/onlinepubs/000095399/ The latter is also known as the Single Unix Specification v3 (SUSv3). HTH