1 #include <unistd.h> // for sleep()
2 #include <stdio.h> // for perror()
3 #include <stdlib.h> // for exit()
8 #include <dispatch/dispatch.h>
9 dispatch_semaphore_t sem
, sem2
;
11 #include <semaphore.h>
19 dispatch_semaphore_signal(sem
);
20 dispatch_semaphore_wait(sem2
, DISPATCH_TIME_FOREVER
);
28 kill_non_lisp_thread(void)
33 if(!(sem
= dispatch_semaphore_create(0)) ||
34 !(sem2
= dispatch_semaphore_create(0))) {
35 perror("dispatch_semaphore_create");
39 if (sem_init(&sem
, 0, 0) || sem_init(&sem2
, 0, 0)) {
45 if (pthread_create(&kid
, 0, (void *(*)(void *))wait_a_bit
, 0) < 0) {
46 perror("pthread_create");
51 dispatch_semaphore_wait(sem
, DISPATCH_TIME_FOREVER
);
56 if (pthread_kill(kid
, SIGURG
)) {
57 perror("pthread_kill");
61 dispatch_semaphore_signal(sem2
);