aboutsummaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-10-05 12:30:09 -0700
committerJunio C Hamano <gitster@pobox.com>2015-10-05 12:30:09 -0700
commit88bad58d3860a8e0cf6499951e24311d15bc63f0 (patch)
treec9e325c9983e51b616090626ab436bef56c9731d /run-command.c
parentdb9789ab4ea05c42c08d7c77f87875476eb78d0d (diff)
parentfd89433dd03babb6c8d760092c3e499f6a4145f4 (diff)
downloadgit-88bad58d3860a8e0cf6499951e24311d15bc63f0.tar.gz
git-88bad58d3860a8e0cf6499951e24311d15bc63f0.tar.xz
Merge branch 'jk/async-pkt-line'
The debugging infrastructure for pkt-line based communication has been improved to mark the side-band communication specifically. * jk/async-pkt-line: pkt-line: show packets in async processes as "sideband" run-command: provide in_async query function
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/run-command.c b/run-command.c
index 3277cf797..c8029f239 100644
--- a/run-command.c
+++ b/run-command.c
@@ -595,7 +595,7 @@ static NORETURN void die_async(const char *err, va_list params)
{
vreportf("fatal: ", err, params);
- if (!pthread_equal(main_thread, pthread_self())) {
+ if (in_async()) {
struct async *async = pthread_getspecific(async_key);
if (async->proc_in >= 0)
close(async->proc_in);
@@ -614,6 +614,13 @@ static int async_die_is_recursing(void)
return ret != NULL;
}
+int in_async(void)
+{
+ if (!main_thread_set)
+ return 0; /* no asyncs started yet */
+ return !pthread_equal(main_thread, pthread_self());
+}
+
#else
static struct {
@@ -653,6 +660,12 @@ int git_atexit(void (*handler)(void))
}
#define atexit git_atexit
+static int process_is_async;
+int in_async(void)
+{
+ return process_is_async;
+}
+
#endif
int start_async(struct async *async)
@@ -712,6 +725,7 @@ int start_async(struct async *async)
if (need_out)
close(fdout[0]);
git_atexit_clear();
+ process_is_async = 1;
exit(!!async->proc(proc_in, proc_out, async->data));
}