]> git.ipfire.org Git - thirdparty/git.git/commit - run-command.c
run-command: add note about forking and threading
authorBrandon Williams <bmwill@google.com>
Wed, 19 Apr 2017 23:13:26 +0000 (16:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Apr 2017 00:55:32 +0000 (17:55 -0700)
commite503cd6ed336d70d716e194ef6c5469330bea9da
tree85e6ecdb24137b1d66f336f2e7efbe5615edc468
parent53fa6753b30c4fb4ea768d16d41d723ea19a3b00
run-command: add note about forking and threading

All non-Async-Signal-Safe functions (e.g. malloc and die) were removed
between 'fork' and 'exec' in start_command in order to avoid potential
deadlocking when forking while multiple threads are running.  This
deadlocking is possible when a thread (other than the one forking) has
acquired a lock and didn't get around to releasing it before the fork.
This leaves the lock in a locked state in the resulting process with no
hope of it ever being released.

Add a note describing this potential pitfall before the call to 'fork()'
so people working in this section of the code know to only use
Async-Signal-Safe functions in the child process.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
run-command.c