Skip to content

Commit b992fe1

Browse files
larsxschneidergitster
authored andcommitted
run-command: move check_pipe() from write_or_die to run_command
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 <[email protected]> Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed54970 commit b992fe1

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

run-command.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ int in_async(void)
634634
return !pthread_equal(main_thread, pthread_self());
635635
}
636636

637-
void NORETURN async_exit(int code)
637+
static void NORETURN async_exit(int code)
638638
{
639639
pthread_exit((void *)(intptr_t)code);
640640
}
@@ -684,13 +684,26 @@ int in_async(void)
684684
return process_is_async;
685685
}
686686

687-
void NORETURN async_exit(int code)
687+
static void NORETURN async_exit(int code)
688688
{
689689
exit(code);
690690
}
691691

692692
#endif
693693

694+
void check_pipe(int err)
695+
{
696+
if (err == EPIPE) {
697+
if (in_async())
698+
async_exit(141);
699+
700+
signal(SIGPIPE, SIG_DFL);
701+
raise(SIGPIPE);
702+
/* Should never happen, but just in case... */
703+
exit(141);
704+
}
705+
}
706+
694707
int start_async(struct async *async)
695708
{
696709
int need_in, need_out;

run-command.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ struct async {
139139
int start_async(struct async *async);
140140
int finish_async(struct async *async);
141141
int in_async(void);
142-
void NORETURN async_exit(int code);
142+
void check_pipe(int err);
143143

144144
/**
145145
* This callback should initialize the child process and preload the

write_or_die.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
#include "cache.h"
22
#include "run-command.h"
33

4-
static void check_pipe(int err)
5-
{
6-
if (err == EPIPE) {
7-
if (in_async())
8-
async_exit(141);
9-
10-
signal(SIGPIPE, SIG_DFL);
11-
raise(SIGPIPE);
12-
/* Should never happen, but just in case... */
13-
exit(141);
14-
}
15-
}
16-
174
/*
185
* Some cases use stdio, but want to flush after the write
196
* to get error handling (and to get better interactive

0 commit comments

Comments
 (0)