1 #include <dlfcn.h>
2 #include <err.h>
3 #include <unistd.h>
4 
5 int
6 main(void)
7 {
8 	static const char msg1[] = "main started\n";
9 	static const char msg2[] = "main after dlopen\n";
10 	static const char msg3[] = "main terminated\n";
11 
12 	void *handle;
13 
14 	write(STDOUT_FILENO, msg1, sizeof(msg1) - 1);
15 	handle = dlopen("h_initfini3_dso.so", RTLD_NOW | RTLD_LOCAL);
16 	if (handle == NULL)
17 		err(1, "dlopen");
18 	write(STDOUT_FILENO, msg2, sizeof(msg2) - 1);
19 	dlclose(handle);
20 	write(STDOUT_FILENO, msg3, sizeof(msg3) - 1);
21 	return 0;
22 }
23