summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2018-01-21 20:55:46 +0000
committerCarlos Martín Nieto <cmn@dwim.me>2018-01-21 21:09:52 +0000
commit8b66a8c6ec6dedd2a80d1c9d35eafebf49f5cead (patch)
treea9504277bdde528c3157fd614a814a9d3916de68 /include
parent820370fe846167faaeabb2238cae900489af6bb8 (diff)
downloadlibgit2-cmn/atexit-skeleton.tar.gz
atexit: create skeletoncmn/atexit-skeleton
This provides a skeleton for registering rollback functions in case the caller wants to centralise their error handling in an `atexit(3)`-like manner. Subsystems within libgit2 will register themselves when they e.g. create lockfiles. If the caller detects an error (potentially unrelated to the libgit2 operation) and wants to back out, they could call `git_atexit()` in order to remove lockfiles which the library is holding.
Diffstat (limited to 'include')
-rw-r--r--include/git2/atexit.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/git2/atexit.h b/include/git2/atexit.h
new file mode 100644
index 000000000..cab8e1872
--- /dev/null
+++ b/include/git2/atexit.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_git_atexit_h__
+#define INCLUDE_git_atexit_h__
+
+#include "common.h"
+
+/**
+ * Execute cleanup for in-process operations
+ *
+ * This will e.g. delete lockfiles we own.
+ */
+GIT_EXTERN(int) git_atexit(void);
+
+#endif /* INCLUDE_git_atexit_h__ */