run-command: prepare command before forking
commit3967e25be11ab96ced71f16b9f082de270a518db
authorBrandon Williams <bmwill@google.com>
Wed, 19 Apr 2017 23:13:19 +0000 (19 16:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Apr 2017 00:55:32 +0000 (20 17:55 -0700)
treec9f8232ead9d4dfa5f6667054f1ab0decb1218f7
parentc2d3119d7bb2122a715d2adac1574514aeff7723
run-command: prepare command before forking

According to [1] we need to only call async-signal-safe operations between fork
and exec.  Using malloc to build the argv array isn't async-signal-safe.

In order to avoid allocation between 'fork()' and 'exec()' prepare the
argv array used in the exec call prior to forking the process.

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/fork.html

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