Skip to content

Commit

Permalink
run-command: move check_pipe() from write_or_die to run_command
Browse files Browse the repository at this point in the history
Move check_pipe() to run_command and make it public. This is necessary
to call the function from pkt-line in a subsequent patch.

While at it, make async_exit() static to run_command.c as it is no
longer used from outside.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
larsxschneider authored and gitster committed Oct 17, 2016
1 parent ed54970 commit b992fe1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
17 changes: 15 additions & 2 deletions run-command.c
Expand Up @@ -634,7 +634,7 @@ int in_async(void)
return !pthread_equal(main_thread, pthread_self());
}

void NORETURN async_exit(int code)
static void NORETURN async_exit(int code)
{
pthread_exit((void *)(intptr_t)code);
}
Expand Down Expand Up @@ -684,13 +684,26 @@ int in_async(void)
return process_is_async;
}

void NORETURN async_exit(int code)
static void NORETURN async_exit(int code)
{
exit(code);
}

#endif

void check_pipe(int err)
{
if (err == EPIPE) {
if (in_async())
async_exit(141);

signal(SIGPIPE, SIG_DFL);
raise(SIGPIPE);
/* Should never happen, but just in case... */
exit(141);
}
}

int start_async(struct async *async)
{
int need_in, need_out;
Expand Down
2 changes: 1 addition & 1 deletion run-command.h
Expand Up @@ -139,7 +139,7 @@ struct async {
int start_async(struct async *async);
int finish_async(struct async *async);
int in_async(void);
void NORETURN async_exit(int code);
void check_pipe(int err);

/**
* This callback should initialize the child process and preload the
Expand Down
13 changes: 0 additions & 13 deletions write_or_die.c
@@ -1,19 +1,6 @@
#include "cache.h"
#include "run-command.h"

static void check_pipe(int err)
{
if (err == EPIPE) {
if (in_async())
async_exit(141);

signal(SIGPIPE, SIG_DFL);
raise(SIGPIPE);
/* Should never happen, but just in case... */
exit(141);
}
}

/*
* Some cases use stdio, but want to flush after the write
* to get error handling (and to get better interactive
Expand Down

0 comments on commit b992fe1

Please sign in to comment.