[Tarantool-patches] [PATCH 1/5] popen: Introduce a backend engine

Cyrill Gorcunov gorcunov at gmail.com
Sat Nov 30 10:36:28 MSK 2019


On Sat, Nov 30, 2019 at 07:14:05AM +0300, Konstantin Osipov wrote:
> * Cyrill Gorcunov <gorcunov at gmail.com> [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().


More information about the Tarantool-patches mailing list