Skip to content

Commit 5d57c6d

Browse files
committed
gvfs-helper-client: clean up server process
On Linux, the following command would cause the terminal to be stuck waiting: git fetch origin foobar The issue would be that the fetch would fail with the error fatal: couldn't find remote ref foobar but the underlying git-gvfs-helper process wouldn't die. The subprocess_exit_handler() method would close its stdin and stdout, but that wouldn't be enough to cause the process to end. The current appraoch creates our own atexit() handler by sending a SIGINT signal to the child process. This has worked in my end-to-end test. Perhaps another approach would be to investigate why the git-gvfs-helper server does not terminate when its stdin closes. Reported-by: Stuart Wilcox Humilde <[email protected]> Signed-off-by: Derrick Stolee <[email protected]>
1 parent 1030eb5 commit 5d57c6d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

gvfs-helper-client.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ static struct object_directory *gh_client__chosen_odb;
3838
#define CAP_OBJECTS__VERB_POST_NAME "post"
3939
#define CAP_OBJECTS__VERB_PREFETCH_NAME "prefetch"
4040

41+
static int server_process_pid = 0;
42+
43+
static void cleanup_server_process_on_exit(void)
44+
{
45+
if (server_process_pid) {
46+
kill(server_process_pid, SIGINT);
47+
server_process_pid = 0;
48+
}
49+
}
50+
4151
static int gh_client__start_fn(struct subprocess_entry *subprocess)
4252
{
4353
static int versions[] = {1, 0};
@@ -48,6 +58,8 @@ static int gh_client__start_fn(struct subprocess_entry *subprocess)
4858

4959
struct gh_server__process *entry = (struct gh_server__process *)subprocess;
5060

61+
server_process_pid = subprocess->process.pid;
62+
atexit(cleanup_server_process_on_exit);
5163
return subprocess_handshake(subprocess, "gvfs-helper", versions,
5264
NULL, capabilities,
5365
&entry->supported_capabilities);

0 commit comments

Comments
 (0)