]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dyld_process_info_unload.dtest/target.c
dyld-832.7.1.tar.gz
[apple/dyld.git] / testing / test-cases / dyld_process_info_unload.dtest / target.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <dlfcn.h>
5 #include <unistd.h>
6 #include <dispatch/dispatch.h>
7
8 #include "test_support.h"
9
10 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
11 signal(SIGUSR1, SIG_IGN);
12 dispatch_source_t signalSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, getppid(),
13 DISPATCH_PROC_EXIT, dispatch_get_main_queue());
14 dispatch_source_set_event_handler(signalSource, ^{
15 exit(0);
16 });
17 dispatch_resume(signalSource);
18
19 dispatch_async(dispatch_get_main_queue(), ^{
20 LOG("target starting");
21 usleep(1000);
22 // load and unload in a loop
23 for (int i=1; i < 10000; ++i) {
24 void* h = dlopen("./libfoo.dylib", 0);
25 usleep(100000/(i*100));
26 dlclose(h);
27 }
28 LOG("target done");
29 });
30
31 dispatch_main();
32 }
33