[CRIU] [PATCH 2/3] crtools: check for setproctitle_init

Ruslan Kuprieiev kupruser at gmail.com
Wed Aug 6 12:56:23 PDT 2014


Check for setproctitle_init, as old versions of libbsd don't have one.

Reported-by: Kir Kolyshkin <kir at openvz.org>
Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 Makefile.config           |  3 +++
 include/setproctitle.h    |  8 ++++++++
 scripts/feature-tests.mak | 13 +++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/Makefile.config b/Makefile.config
index 9f1857d..ac54775 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -33,6 +33,9 @@ endif
 ifeq ($(VDSO),y)
 	$(Q) @echo '#define CONFIG_VDSO' >> $@
 endif
+ifeq ($(call try-cc,$(SETPROCTITLE_INIT_TEST),-lbsd),y)
+	$(Q) @echo '#define CONFIG_HAS_SETPROCTITLE_INIT' >> $@
+endif
 	$(Q) @echo '#endif /* __CR_CONFIG_H__ */' >> $@
 
 config: $(CONFIG)
diff --git a/include/setproctitle.h b/include/setproctitle.h
index ed6bf03..5a10cba 100644
--- a/include/setproctitle.h
+++ b/include/setproctitle.h
@@ -4,7 +4,15 @@
 #ifdef CONFIG_HAS_LIBBSD
 #include <bsd/unistd.h>
 #else
+
+/*
+ * setproctitle_init is in the libbsd since v0.6.0. This macro allows to
+ * compile criu with libbsd<0.6.0.
+ */
+#ifndef CONFIG_HAS_SETPROCTITLE_INIT
 #define setproctitle_init(argc, argv, envp)
+#endif
+
 #define setproctitle(fmt, ...)
 #endif
 
diff --git a/scripts/feature-tests.mak b/scripts/feature-tests.mak
index 0977857..519eb52 100644
--- a/scripts/feature-tests.mak
+++ b/scripts/feature-tests.mak
@@ -79,3 +79,16 @@ int main(void)
 }
 
 endef
+
+define SETPROCTITLE_INIT_TEST
+
+#include <bsd/unistd.h>
+
+int main(int argc, char *argv[], char *envp[])
+{
+	setproctitle_init(argc, argv, envp);
+
+	return 0;
+}
+
+endef
-- 
1.9.1



More information about the CRIU mailing list