From 120b49397822010fc232e1bfe184a85482a27954 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux <ajanni@videolabs.io> Date: Thu, 3 Apr 2025 10:09:35 +0200 Subject: [PATCH] darwinvlc: remove SIGCHLD GCD handling The handling through GCD was added back then in commit cc07bce0d25c0defcd5576005515df3b0a7531bb. In that commit, signal(SIGCHLD, SIG_DFL) was already called to ensure the behavior of the signal is restored to default handlers. In `man 3 signal` from the macos manual, it is said that when setting SIG_IGN for SIGCHLD, the operating system will not create zombie process and the exit status will be ignored. We do want to avoid creating zombie process but we also want to have exit status, which means we do indeed need the SIG_DFL handler here. See also the following commit on the linux side: 94763831fb59701a30f7e55c8ce9258ddbeeff18. However, GCD was used to automatically call waitpid() on the process that are being signalled as closing. Since we're always calling waitpid when spawning any process, this duplicates the handling. But the clients are actually using vlc_waitpid which is checking errno != ECHILD, so it would break as soon as the GCD handler is executed before the vlc_waitpid call. Since every cases are explicitely calling vlc_waitpid(), do as linux and just remove the specific GCD handling. Co-authored-by: Marvin Scholz <epirat07@gmail.com> Fixes #29099 --- bin/darwinvlc.m | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/bin/darwinvlc.m b/bin/darwinvlc.m index 119c40b5c7f2..e9f411fb65f6 100644 --- a/bin/darwinvlc.m +++ b/bin/darwinvlc.m @@ -204,9 +204,8 @@ int main(int i_argc, const char *ppsz_argv[]) dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_source_t sigIntSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGINT, 0, queue); dispatch_source_t sigTermSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, queue); - dispatch_source_t sigChldSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGCHLD, 0, queue); - if (!sigIntSource || !sigTermSource || !sigChldSource) + if (!sigIntSource || !sigTermSource) abort(); dispatch_source_set_event_handler(sigIntSource, ^{ @@ -216,16 +215,8 @@ int main(int i_argc, const char *ppsz_argv[]) vlc_terminate(nil); }); - dispatch_source_set_event_handler(sigChldSource, ^{ - int status; - while(waitpid(-1, &status, WNOHANG) > 0) - ; - }); - dispatch_resume(sigIntSource); dispatch_resume(sigTermSource); - dispatch_resume(sigChldSource); - /* Handle parameters */ const char **argv = calloc(i_argc + 2, sizeof (argv[0])); @@ -320,7 +311,6 @@ out: dispatch_release(sigIntSource); dispatch_release(sigTermSource); - dispatch_release(sigChldSource); if (vlc) libvlc_release(vlc); -- GitLab