OSDN Git Service

libqtest: ensure waitpid() is only called once
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 13 Jan 2023 11:01:20 +0000 (12:01 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 11 Feb 2023 08:20:38 +0000 (09:20 +0100)
commit12008ff748d8cfb62fb937559c0fd844371bab5e
tree0eb0416e451aecf9edbe32b5db20dd2f9bfdce3f
parent786c5256d3262518d8805ac2a62eb1c4a3813b80
libqtest: ensure waitpid() is only called once

If a test aborts after qtest_wait_qemu() is called, the SIGABRT hooks are
still in place and waitpid() is called again.  The second time it is called,
the process does not exist anymore and the system call fails.

Move the s->qemu_pid = -1 assignment to qtest_wait_qemu() to make it
idempotent, and anyway remove the SIGABRT hook as well to avoid that
qtest_check_status() is called twice.  Because of the extra call,
qtest_remove_abrt_handler() now has to be made idempotent as well.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tests/qtest/libqtest.c