Skip to content

Commit ec4c231

Browse files
dschogitster
authored andcommitted
scalar unregister: stop FSMonitor daemon
Especially on Windows, we will need to stop that daemon, just in case that the directory needs to be removed (the daemon would otherwise hold a handle to that directory, preventing it from being deleted). Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f1917d commit ec4c231

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

contrib/scalar/scalar.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ static int start_fsmonitor_daemon(void)
244244
return 0;
245245
}
246246

247+
static int stop_fsmonitor_daemon(void)
248+
{
249+
assert(have_fsmonitor_support());
250+
251+
if (fsmonitor_ipc__get_state() == IPC_STATE__LISTENING)
252+
return run_git("fsmonitor--daemon", "stop", NULL);
253+
254+
return 0;
255+
}
256+
247257
static int register_dir(void)
248258
{
249259
if (add_or_remove_enlistment(1))
@@ -468,6 +478,9 @@ static int delete_enlistment(struct strbuf *enlistment)
468478
strbuf_release(&parent);
469479
#endif
470480

481+
if (have_fsmonitor_support() && stop_fsmonitor_daemon())
482+
return error(_("failed to stop the FSMonitor daemon"));
483+
471484
if (remove_dir_recursively(enlistment, 0))
472485
return error(_("failed to delete enlistment directory"));
473486

0 commit comments

Comments
 (0)