slirp: fork_exec(): create and connect child socket before fork()
commit5c75f3adbbfcdf8fae6e74875b44efb8d928974a
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 6 Nov 2018 15:13:23 +0000 (6 15:13 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 10 Nov 2018 14:07:53 +0000 (10 15:07 +0100)
treea4a505288b3fa853c28f6edddefbe5d3c1fca74c
parent4ded9bb54ceefeb68e766fe9aafc10de934c4501
slirp: fork_exec(): create and connect child socket before fork()

Currently fork_exec() fork()s, and then creates and connects the
child socket which it uses for communication with the parent in
the child process. This is awkward because the child has no
mechanism to report failure back to the parent, which might end
up blocked forever in accept(). The child code also has an issue
pointed out by Coverity (CID 1005727), where if the qemu_socket()
call fails it will pass -1 as a file descriptor to connect().

Fix these issues by moving the creation of the child's end of
the socket to before the fork(), where we are in a position to
handle a possible failure.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
slirp/misc.c