From ccd62bb4d88bafc4472ec8a69d92bc5d4b3411d7 Mon Sep 17 00:00:00 2001 From: Yuxiao Mao Date: Mon, 29 Apr 2024 14:29:40 +0200 Subject: [PATCH] Fix wrong error on process exit Linux --- hldebug-wrapper/src/debug.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hldebug-wrapper/src/debug.c b/hldebug-wrapper/src/debug.c index a3a4612..3f8dcf5 100644 --- a/hldebug-wrapper/src/debug.c +++ b/hldebug-wrapper/src/debug.c @@ -256,9 +256,11 @@ HL_API int hl_debug_wait( int pid, int *thread, int timeout ) { // With it, and more we wait, less we miss stop event. usleep(100 * 1000); int ret = waitpid(pid, &status, WNOHANG); + if( ret == -1 && errno == ECHILD ) { + *thread = pid; + return 0; + } *thread = ret; - if( ret == -1 && errno != EINTR ) - return 3; if( ret <= 0 ) return -1; if( WIFEXITED(status) )