git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/5] index-helper: add --detach

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jun 10, 2014, 13:24 UTC
Message-ID
<1402406665-27988-6-git-send-email-pclouds@gmail.com>
In-Reply-To
<1402406665-27988-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/git-index-helper.txt | 4 +++-
 index-helper.c                     | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-index-helper.txt b/Documentation/git-index-helper.txt
index afeb334..303cda0 100644
--- a/Documentation/git-index-helper.txt
+++ b/Documentation/git-index-helper.txt
@@ -8,7 +8,7 @@ git-index-helper - A simple cache server for speeding up index file access
 SYNOPSIS
 --------
 [verse]
-'git index-helper
+'git index-helper [--detach]
 
 DESCRIPTION
 -----------
@@ -18,6 +18,8 @@ shared memory support (e.g. Linux or Windows)
 
 OPTIONS
 -------
+--detach::
+	Detach from the shell.
 
 GIT
 ---
diff --git a/index-helper.c b/index-helper.c
index f92326a..9420591 100644
--- a/index-helper.c
+++ b/index-helper.c
@@ -159,8 +159,9 @@ int main(int argc, char **argv)
 	static struct lock_file lock;
 	struct strbuf sb = STRBUF_INIT;
 	const char *prefix;
-	int fd;
+	int fd, detach = 0;
 	struct option options[] = {
+		OPT_BOOL(0, "detach", &detach, "detach the process"),
 		OPT_END()
 	};
 
@@ -188,6 +189,9 @@ int main(int argc, char **argv)
 	sigchain_push(SIGQUIT, cleanup_on_signal);
 	sigchain_push(SIGPIPE, cleanup_on_signal);
 
+	if (detach && daemonize(&daemonized))
+		die_errno("unable to detach");
+
 	loop(sb.buf, 600);
 	strbuf_release(&sb);
 	return 0;
-- 
1.9.1.346.ga2b5940
Previous: Nguyễn Thái Ngọc Duy
Message 7 of 7 in “Speed up cache loading time”
  1. 0/5 Speed up cache loading timeNguyễn Thái Ngọc Duy, Jun 10, 2014
  2. 1/5 read-cache: allow to keep mmap'd memory after readingNguyễn Thái Ngọc Duy, Jun 10, 2014
  3. 2/5 index-helper: new daemon for caching index and related stuffNguyễn Thái Ngọc Duy, Jun 10, 2014
  4. David TurnerJun 10, 2014
  5. 3/5 index-helper: add Windows supportNguyễn Thái Ngọc Duy, Jun 10, 2014
  6. 4/5 daemonize(): set a flag before exiting the main processNguyễn Thái Ngọc Duy, Jun 10, 2014
  7. 5/5 index-helper: add --detachNguyễn Thái Ngọc Duy, Jun 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.