From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (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 87CC146970F for ; Sat, 30 Nov 2019 10:36:31 +0300 (MSK) Received: by mail-lf1-f67.google.com with SMTP id f16so24180785lfm.3 for ; Fri, 29 Nov 2019 23:36:31 -0800 (PST) Date: Sat, 30 Nov 2019 10:36:28 +0300 From: Cyrill Gorcunov Message-ID: <20191130073628.GP19879@uranus> References: <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> <20191130041405.GB31199@atlas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191130041405.GB31199@atlas> 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 Sat, Nov 30, 2019 at 07:14:05AM +0300, Konstantin Osipov wrote: > * Cyrill Gorcunov [19/11/30 07:03]: > > Once we sart using non-blocking IO the read() could return -EAGAIN. > > I think I need to find out how python is handling this situation, > > is their read is blocking or not. > > Take a look at how coio works. It adds the descriptor to the event > loop and yields the current fiber. I will, thanks! You know there is another problem with nonblocking descriptors: consider a case where user runs a script like in my test "input=''; read -n 5 input; echo $input". If you run it inside a regular terminal the script will wait for input to apprear first, but if we provide nonblocking pipe the "read" will exit with -EAGAIN and script fail. Actually my first implementations have been creating pipes with O_NONBLOCK and since such test case start to fail I dropped O_NONBLOCK then. > > 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. > > Can't you check the pid > 0 before you send the signal? This won't work, a signal can interrupt us in any moment and set the pid to -1 between if() and kill().