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

Cyrill Gorcunov gorcunov at gmail.com
Sat Nov 30 01:36:50 MSK 2019


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.


More information about the Tarantool-patches mailing list