From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RMHuM-0007G8-M4 for qemu-devel@nongnu.org; Fri, 04 Nov 2011 07:26:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RMHuL-0007Sy-KQ for qemu-devel@nongnu.org; Fri, 04 Nov 2011 07:26:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64673) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RMHuL-0007Sk-Bt for qemu-devel@nongnu.org; Fri, 04 Nov 2011 07:26:01 -0400 Message-ID: <4EB3CBAC.8070005@redhat.com> Date: Fri, 04 Nov 2011 12:25:32 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1319797077-25441-1-git-send-email-pbonzini@redhat.com> <1319797077-25441-5-git-send-email-pbonzini@redhat.com> <67C69C1A-BA12-4DD6-8CFE-F97011B68258@irisa.fr> <4EAA98B4.4030800@redhat.com> <90216E5F-CF18-4A44-BBCF-0DFB68259296@irisa.fr> <4EAA9D65.1080108@redhat.com> <4EB3B48D.706@redhat.com> <4EB3BF1D.8070108@redhat.com> <4EB3C826.9030005@redhat.com> <4EB3CAF2.30703@redhat.com> In-Reply-To: <4EB3CAF2.30703@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/4] qemu-nbd: do not start the block layer in the parent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, Pierre Riteau On 11/04/2011 12:22 PM, Kevin Wolf wrote: >> > >> > That's exactly what this series did. However, daemonization has also to >> > be done before opening the image file. So the series has to support >> > reporting errors to syslog, and also qemu-nbd will not give a nonzero >> > exit status when errors occur. > > The parent could wait until the initialisation is done. You need to daemonize first, then fork the server. If you fork the server before daemonizing, the server: 1) is not in its own process group, and still has a controlling TTY; 2) is not your child so your process structure is all broken, with the client and server being both child of PID 1; 3) is not your child, so you cannot reliably kill it (because if it has exited and PID 1 has already reaped it, you might kill a random process instead!). Paolo