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

Ruslan Kuprieiev kupruser at gmail.com
Thu Mar 27 14:52:24 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 ca46ca1..a4e234f 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -30,6 +30,9 @@ endif
 ifeq ($(call try-cc,$(PTRACE_PEEKSIGINFO_TEST),),y)
 	$(Q) @echo '#define CONFIG_HAS_PEEKSIGINFO_ARGS' >> $@
 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..3ac1f23 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 crtools with libbsd<0.6.0.
+ */
+#ifndef CONFIG_HAS_SETPROCTITLE_INIT
 void setproctitle_init(int argc, char *argv[], char *envp[]) {return; }
+#endif
+
 void setproctitle(const char *fmt, ...) {return; }
 #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.8.3.2



More information about the CRIU mailing list