summaryrefslogtreecommitdiffstats
path: root/regress/libexec/ld.so/init-env/prog/prog.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2016-03-20 05:13:22 +0000
committerguenther <guenther@openbsd.org>2016-03-20 05:13:22 +0000
commit5827e47d54b095cd7dc0c2424f88c2ddf01c87d2 (patch)
tree0e733957dfd37139d76c223ddf8e46c7d1676841 /regress/libexec/ld.so/init-env/prog/prog.c
parentIt's libpthread, not librthread, and __tfork(2) lets you set the TCB (diff)
downloadwireguard-openbsd-5827e47d54b095cd7dc0c2424f88c2ddf01c87d2.tar.xz
wireguard-openbsd-5827e47d54b095cd7dc0c2424f88c2ddf01c87d2.zip
Add regress for environ and __progname vs load-time .init functions
Diffstat (limited to '')
-rw-r--r--regress/libexec/ld.so/init-env/prog/prog.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/regress/libexec/ld.so/init-env/prog/prog.c b/regress/libexec/ld.so/init-env/prog/prog.c
new file mode 100644
index 00000000000..c7d1f9ded26
--- /dev/null
+++ b/regress/libexec/ld.so/init-env/prog/prog.c
@@ -0,0 +1,31 @@
+/*
+ * Public Domain 2016 Philip Guenther <guenther@openbsd.org>
+ *
+ * $OpenBSD: prog.c,v 1.1 2016/03/20 05:13:22 guenther Exp $
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+extern char **environ;
+
+int
+main(int argc, char **argv, char **env)
+{
+ int ret = 0;
+
+ if (env == environ)
+ printf("OK: main's 3rd arg == environ\n");
+ else {
+ ret = 1;
+ printf("FAILED: main's 3rd arg isn't environ\n");
+ }
+ if (getenv("INIT_ENV_REGRESS_TEST") != NULL)
+ printf("OK: env var set by .so init function set\n");
+ else {
+ ret = 1;
+ printf("FAILED: env var set by .so init function not set\n");
+ }
+
+ return ret;
+}