Ver código fonte

LibC+LibPthread: Permit partial pthread_atfork

POSIX explicitly allows providing nullptr's, and our __pthread_*() implementation
stores and calls the provided functions as-is, without checking for nullptr.
Ben Wiederhake 4 anos atrás
pai
commit
cf0d4994c2
1 arquivos alterados com 6 adições e 3 exclusões
  1. 6 3
      Userland/Libraries/LibPthread/pthread.cpp

+ 6 - 3
Userland/Libraries/LibPthread/pthread.cpp

@@ -900,9 +900,12 @@ int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int)
 
 int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
 {
-    __pthread_fork_atfork_register_prepare(prepare);
-    __pthread_fork_atfork_register_parent(parent);
-    __pthread_fork_atfork_register_child(child);
+    if (prepare)
+        __pthread_fork_atfork_register_prepare(prepare);
+    if (parent)
+        __pthread_fork_atfork_register_parent(parent);
+    if (child)
+        __pthread_fork_atfork_register_child(child);
     return 0;
 }