[vlc-commits] [Git][videolan/vlc][master] darwinvlc: remove SIGCHLD GCD handling

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Mon Apr 14 19:01:22 UTC 2025



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
120b4939 by Alexandre Janniaux at 2025-04-14T18:46:49+00:00
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 at gmail.com>

Fixes #29099

- - - - -


1 changed file:

- bin/darwinvlc.m


Changes:

=====================================
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);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/120b49397822010fc232e1bfe184a85482a27954

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/120b49397822010fc232e1bfe184a85482a27954
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list