8 #include <dispatch/dispatch.h>
10 void performDylibOperations(void) {
11 for (int i
=0; i
< 3; ++i
) {
12 void* h
= dlopen(RUN_DIR
"/libfoo.dylib", 0);
15 fprintf(stderr
, "Done (pid: %d)\n", getpid());
19 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
20 signal(SIGUSR1
, SIG_IGN
);
21 dispatch_source_t signalSource
= dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC
, getppid(),
22 DISPATCH_PROC_EXIT
, dispatch_get_main_queue());
23 dispatch_source_set_event_handler(signalSource
, ^{
26 dispatch_resume(signalSource
);
28 if ( (argc
> 1) && (strcmp(argv
[1], "suspend-in-main") == 0) ) {
29 dispatch_source_t signalSourceSource
= dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL
,
30 SIGUSR1
, 0, dispatch_get_main_queue());
31 dispatch_source_set_event_handler(signalSourceSource
, ^{
32 performDylibOperations();
34 dispatch_resume(signalSourceSource
);
35 dispatch_async(dispatch_get_main_queue(), ^{
36 fprintf(stderr
, "Ready (pid: %d)\n", getpid());
39 performDylibOperations();