From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A2FD146970F for ; Sat, 30 Nov 2019 01:36:53 +0300 (MSK) Received: by mail-lf1-f68.google.com with SMTP id l18so5607784lfc.1 for ; Fri, 29 Nov 2019 14:36:53 -0800 (PST) Date: Sat, 30 Nov 2019 01:36:50 +0300 From: Cyrill Gorcunov Message-ID: <20191129223650.GO19879@uranus> References: <20191128204512.19732-1-gorcunov@gmail.com> <20191128204512.19732-2-gorcunov@gmail.com> <20191129055939.GH15149@atlas> <20191129094059.GA19879@uranus> <20191129111903.GA7760@atlas> <20191129113659.GE19879@uranus> <20191129145028.GA18043@atlas> <20191129151410.GJ19879@uranus> <20191129183144.GB16921@atlas> <20191129191708.GN19879@uranus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191129191708.GN19879@uranus> Subject: Re: [Tarantool-patches] [PATCH 1/5] popen: Introduce a backend engine List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Konstantin Osipov Cc: tml On Fri, Nov 29, 2019 at 10:17:08PM +0300, Cyrill Gorcunov wrote: > > > > We discussed this and pid reuse is impossible unless you collect > > the status of a child. You can easily mark the handle as dead as > > soon as you get sigchild and collect it. I don't see any issue > > here. > > The eio reaps children itself, ie calls for wait. Thus imagine a situation, > we start killing the process like > > popen_kill(handle) > ... > kill(handle->pid) > ... > > but before we reach kill() this process exited by self or killed > by a user on the node. The signal handler sets pid = -1 and we > call kill(-1). Which is wrong of course. You know, without signal blocking I fear we simply won't be able to tack children properly. Look here is an example pid = vfork(); if (pid == 0) { _exit(1); here sigchld already delivered to the libev and it reaped it, vanishing from the system so that anyother application can reuse it } else { ev_child_init(&handle->ev_sigchld, ev_sigchld_cb, pid, 0); ev_child_start(EV_DEFAULT_ &handle->ev_sigchld); but pid already dead and reused by someone else, as I said wait() called under the hood, we simply don't control it } and without signal blocking we can't order pid livetime anyhow. You know in my first versions I setup ev_child_init with pid=0 and been expecting the sgnal handler catches _any_ sigchld but it didn't work :/ Thus early _exit(1) in child process was simply invisible to the rest of tarantool code.