qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] slirp: fork_exec(): Don't close() a negative nu


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] slirp: fork_exec(): Don't close() a negative number in fork_exec()
Date: Tue, 11 Jul 2017 16:17:42 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/11/2017 03:40 PM, Peter Maydell wrote:
>>>
>>> The problem is you can only bail while you're in the parent
>>> before forking. Once you've started the child there's no
>>> mechanism for dealing with failure.
>>
>> Well, you can always exit the child before anything worse can happen.
> 
> You need a mechanism then for causing the parent to notice.
> The current code would leave the parent in a blocking
> accept() call forever (this is what all the XXX comments
> in the current code are about).

You can have the parent create a pipe before forking and does a blocking
read, the child then manages fds and writes success (or failure) to its
end of the pipe (or an early exit causes the parent to read EOF); when
the parent finally gets word on the pipe, then it knows whether the
child is dead-on-arrival due to early setup failures, or whether it is
now safe to block on accept().  But it can easily get more and more
complex the more you want to handle; and if the parent is
multi-threaded, you have to be careful that you only call
async-signal-safe functions in the child between the fork and exec.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]