aboutsummaryrefslogtreecommitdiffstats
path: root/run-command.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-10-24 14:59:10 -0700
committerJunio C Hamano <gitster@pobox.com>2014-10-24 14:59:10 -0700
commite4da4fbe0eea55c26f042f76df58bfc529b46ae0 (patch)
tree7ead155867beb400d6bed1d89be73803305f6d31 /run-command.c
parentbb8caad3814b49316f842a006082e79b4e46125c (diff)
parent0f4b6db3baeff8de53769b38f439408abd5a42f7 (diff)
downloadgit-e4da4fbe0eea55c26f042f76df58bfc529b46ae0.tar.gz
Merge branch 'eb/no-pthreads'
Allow us build with NO_PTHREADS=NoThanks compilation option. * eb/no-pthreads: Handle atexit list internaly for unthreaded builds pack-objects: set number of threads before checking and warning index-pack: fix compilation with NO_PTHREADS
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/run-command.c b/run-command.c
index 46be513c48..79a0a763ec 100644
--- a/run-command.c
+++ b/run-command.c
@@ -626,6 +626,45 @@ static int async_die_is_recursing(void)
return ret != NULL;
}
+#else
+
+static struct {
+ void (**handlers)(void);
+ size_t nr;
+ size_t alloc;
+} git_atexit_hdlrs;
+
+static int git_atexit_installed;
+
+static void git_atexit_dispatch()
+{
+ size_t i;
+
+ for (i=git_atexit_hdlrs.nr ; i ; i--)
+ git_atexit_hdlrs.handlers[i-1]();
+}
+
+static void git_atexit_clear()
+{
+ free(git_atexit_hdlrs.handlers);
+ memset(&git_atexit_hdlrs, 0, sizeof(git_atexit_hdlrs));
+ git_atexit_installed = 0;
+}
+
+#undef atexit
+int git_atexit(void (*handler)(void))
+{
+ ALLOC_GROW(git_atexit_hdlrs.handlers, git_atexit_hdlrs.nr + 1, git_atexit_hdlrs.alloc);
+ git_atexit_hdlrs.handlers[git_atexit_hdlrs.nr++] = handler;
+ if (!git_atexit_installed) {
+ if (atexit(&git_atexit_dispatch))
+ return -1;
+ git_atexit_installed = 1;
+ }
+ return 0;
+}
+#define atexit git_atexit
+
#endif
int start_async(struct async *async)
@@ -684,6 +723,7 @@ int start_async(struct async *async)
close(fdin[1]);
if (need_out)
close(fdout[0]);
+ git_atexit_clear();
exit(!!async->proc(proc_in, proc_out, async->data));
}