run-command: add note about forking and threading
[gitweb.git] / run-command.c
index 615b6e9c9c77f069254314b93583f56df1a1c0b7..df1edd963f2567486b8d7bbb2926e0320f8dac71 100644 (file)
@@ -537,6 +537,15 @@ int start_command(struct child_process *cmd)
        prepare_cmd(&argv, cmd);
        childenv = prep_childenv(cmd->env);
 
+       /*
+        * NOTE: In order to prevent deadlocking when using threads special
+        * care should be taken with the function calls made in between the
+        * fork() and exec() calls.  No calls should be made to functions which
+        * require acquiring a lock (e.g. malloc) as the lock could have been
+        * held by another thread at the time of forking, causing the lock to
+        * never be released in the child process.  This means only
+        * Async-Signal-Safe functions are permitted in the child.
+        */
        cmd->pid = fork();
        failed_errno = errno;
        if (!cmd->pid) {