Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit ed7eda8

Browse files
mackylegitster
authored andcommitted
gc: notice gc processes run by other users
Since 64a99eb git gc refuses to run without the --force option if another gc process on the same repository is already running. However, if the repository is shared and user A runs git gc on the repository and while that gc is still running user B runs git gc on the same repository the gc process run by user A will not be noticed and the gc run by user B will go ahead and run. The problem is that the kill(pid, 0) test fails with an EPERM error since user B is not allowed to signal processes owned by user A (unless user B is root). Update the test to recognize an EPERM error as meaning the process exists and another gc should not be run (unless --force is given). Signed-off-by: Kyle J. McKay <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d2446df commit ed7eda8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
222222
time(NULL) - st.st_mtime <= 12 * 3600 &&
223223
fscanf(fp, "%"PRIuMAX" %127c", &pid, locking_host) == 2 &&
224224
/* be gentle to concurrent "gc" on remote hosts */
225-
(strcmp(locking_host, my_host) || !kill(pid, 0));
225+
(strcmp(locking_host, my_host) || !kill(pid, 0) || errno == EPERM);
226226
if (fp != NULL)
227227
fclose(fp);
228228
if (should_exit) {

0 commit comments

Comments
 (0)