diff options
author | 2016-03-20 05:13:22 +0000 | |
---|---|---|
committer | 2016-03-20 05:13:22 +0000 | |
commit | 5827e47d54b095cd7dc0c2424f88c2ddf01c87d2 (patch) | |
tree | 0e733957dfd37139d76c223ddf8e46c7d1676841 /regress/libexec/ld.so/init-env/prog/prog.c | |
parent | It's libpthread, not librthread, and __tfork(2) lets you set the TCB (diff) | |
download | wireguard-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.c | 31 |
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; +} |