libxl: react correctly to bootloader pty master POLLHUP
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 3 Aug 2012 08:54:08 +0000 (09:54 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Fri, 3 Aug 2012 08:54:08 +0000 (09:54 +0100)
commit7253e0fd1aeb3ae7d4714bcc1d86b846b3331995
tree943ea082fe03a56387831bd15b6a36e1ffa70b10
parent2dc6e6ef994ca63c7f9fb49981c1b044a69f2ac1
libxl: react correctly to bootloader pty master POLLHUP

Receive POLLHUP on the bootloader master pty is not an error.
Hopefully it means that the bootloader has exited and therefore the
pty slave side has no process group any more.  (At least NetBSD
indicates POLLHUP on the master in this case.)

So send the bootloader SIGTERM; if it has already exited then this has
no effect (except that on some versions of NetBSD it erroneously
returns ESRCH and we print a harmless warning) and we will then
collect the bootloader's exit status and be satisfied.

However, we remember that we have done this so that if we got POLLHUP
for some other reason than that the bootloader exited we report
something resembling a useful message.

In order to implement this we need to provide a way for users of
datacopier to handle POLLHUP rather than treating it as fatal.

We rename bootloader_abort to bootloader_stop since it now no longer
only applies to error situations.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_aoutils.c
tools/libxl/libxl_bootloader.c
tools/libxl/libxl_internal.h