From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Christian Couder" <christian.couder@gmail.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v4 8/9] index-helper: add --detach
Date: Sun, 1 Nov 2015 14:42:48 +0100 [thread overview]
Message-ID: <1446385369-8669-9-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1446385369-8669-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 | 3 +++
index-helper.c | 10 ++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-index-helper.txt b/Documentation/git-index-helper.txt
index ad40366..9ced091 100644
--- a/Documentation/git-index-helper.txt
+++ b/Documentation/git-index-helper.txt
@@ -31,6 +31,9 @@ OPTIONS
for reading an index, but because it will happen in the
background, it's not noticable. `--strict` is enabled by default.
+--detach::
+ Detach from the shell.
+
NOTES
-----
On UNIX-like systems, $GIT_DIR/index-helper.pid contains the process
diff --git a/index-helper.c b/index-helper.c
index 1140bc0..4dd9656 100644
--- a/index-helper.c
+++ b/index-helper.c
@@ -14,7 +14,7 @@ struct shm {
static struct shm shm_index;
static struct shm shm_base_index;
-static int to_verify = 1;
+static int daemonized, to_verify = 1;
static void release_index_shm(struct shm *is)
{
@@ -33,6 +33,8 @@ static void cleanup_shm(void)
static void cleanup(void)
{
+ if (daemonized)
+ return;
unlink(git_path("index-helper.pid"));
cleanup_shm();
}
@@ -172,12 +174,13 @@ int main(int argc, char **argv)
static struct lock_file lock;
struct strbuf sb = STRBUF_INIT;
const char *prefix;
- int fd, idle_in_minutes = 10;
+ int fd, idle_in_minutes = 10, detach = 0;
struct option options[] = {
OPT_INTEGER(0, "exit-after", &idle_in_minutes,
N_("exit if not used after some minutes")),
OPT_BOOL(0, "strict", &to_verify,
"verify shared memory after creating"),
+ OPT_BOOL(0, "detach", &detach, "detach the process"),
OPT_END()
};
@@ -202,6 +205,9 @@ int main(int argc, char **argv)
atexit(cleanup);
sigchain_push_common(cleanup_on_signal);
+ if (detach && daemonize(&daemonized))
+ die_errno("unable to detach");
+
if (!idle_in_minutes)
idle_in_minutes = 0xffffffff / 60;
loop(sb.buf, idle_in_minutes * 60);
--
2.2.0.513.g477eb31
next prev parent reply other threads:[~2015-11-01 13:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-01 13:42 [PATCH v4 0/9] Reduce index load time Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 1/9] trace.c: add GIT_TRACE_PACK_STATS for pack usage statistics Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 2/9] read-cache.c: fix constness of verify_hdr() Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 3/9] read-cache: allow to keep mmap'd memory after reading Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 4/9] index-helper: new daemon for caching index and related stuff Nguyễn Thái Ngọc Duy
2015-11-02 22:14 ` David Turner
2015-11-01 13:42 ` [PATCH v4 5/9] trace.c: add GIT_TRACE_INDEX_STATS for index statistics Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 6/9] index-helper: add --strict Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` [PATCH v4 7/9] daemonize(): set a flag before exiting the main process Nguyễn Thái Ngọc Duy
2015-11-01 13:42 ` Nguyễn Thái Ngọc Duy [this message]
2015-11-01 13:42 ` [PATCH v4 9/9] index-helper: add Windows support Nguyễn Thái Ngọc Duy
2015-11-16 21:51 ` [PATCH v4 0/9] Reduce index load time Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446385369-8669-9-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).