fsmonitor--daemon: implement 'start' command
commitc284e27ba77ee385d322bb90aeb2284bf52c014b
authorJeff Hostetler <jeffhost@microsoft.com>
Fri, 25 Mar 2022 18:02:54 +0000 (25 18:02 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 Mar 2022 23:04:15 +0000 (25 16:04 -0700)
tree4dac670208f5bf2e4ed619002c2839ab63ba86f2
parent9dcba0ba08d0e843eda1f141c99c72e0aa67811f
fsmonitor--daemon: implement 'start' command

Implement 'git fsmonitor--daemon start' command.  This command starts
an instance of 'git fsmonitor--daemon run' in the background using
the new 'start_bg_command()' function.

We avoid the fork-and-call technique on Unix systems in favor of a
fork-and-exec technique.  This gives us more uniform Trace2 child-*
events.  It also makes our usage more consistent with Windows usage.

On Windows, teach 'git fsmonitor--daemon run' to optionally call
'FreeConsole()' to release handles to the inherited Win32 console
(despite being passed invalid handles for stdin/out/err).  Without
this, command prompts and powershell terminal windows could hang
in "exit" until the last background child process exited or released
their Win32 console handle.  (This was not seen with git-bash shells
because they don't have a Win32 console attached to them.)

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fsmonitor--daemon.c