mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
qtest: kill orphaned qtest QEMU processes on FreeBSD
On Linux we use PR_SET_PDEATHSIG to kill orphaned QEMU processes if we fail to call qtest_quit(), or the test program aborts/segvs. This prevents meson from hanging forever due to the orphaned process keeping stdout open. On FreeBSD we can achieve the same using PROC_PDEATHSIG_CTL, which gives us the equivalent protection against hangs. Signed-off-by: "Daniel P. Berrangé" <berrange@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20230912184130.3056054-3-berrange@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230914155422.426639-6-alex.bennee@linaro.org>
This commit is contained in:
parent
81395b6ec8
commit
49e9f8644b
1 changed files with 7 additions and 0 deletions
|
@ -24,6 +24,9 @@
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <sys/procctl.h>
|
||||||
|
#endif /* __FreeBSD__ */
|
||||||
|
|
||||||
#include "libqtest.h"
|
#include "libqtest.h"
|
||||||
#include "libqmp.h"
|
#include "libqmp.h"
|
||||||
|
@ -414,6 +417,10 @@ static QTestState *G_GNUC_PRINTF(1, 2) qtest_spawn_qemu(const char *fmt, ...)
|
||||||
*/
|
*/
|
||||||
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
|
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
int sig = SIGKILL;
|
||||||
|
procctl(P_PID, getpid(), PROC_PDEATHSIG_CTL, &sig);
|
||||||
|
#endif /* __FreeBSD__ */
|
||||||
if (!g_setenv("QEMU_AUDIO_DRV", "none", true)) {
|
if (!g_setenv("QEMU_AUDIO_DRV", "none", true)) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue