1 /* Test cancellation of a door_return call. */
14 static volatile lwpid_t server_lwpid
= 0;
16 static void server_procedure(void *cookie
, char *argp
, size_t arg_size
,
17 door_desc_t
*dp
, uint_t n_desc
)
22 static void *my_server_thread(void *arg
)
24 server_lwpid
= _lwp_self();
25 door_return(NULL
, 0, NULL
, 0);
29 static void create_door_thread(door_info_t
*info
)
31 static int called
= 0;
35 /* Allow to create only one server door thread. */
39 res
= pthread_create(&thread
, NULL
, my_server_thread
, NULL
);
42 perror("pthread_create");
47 static void signal_handler(int signo
, siginfo_t
*info
, void *uc
)
49 const char str
[] = "Signal caught.\n";
50 size_t len
= sizeof(str
) - 1;
53 res
= write(STDOUT_FILENO
, str
, len
);
63 sa
.sa_sigaction
= signal_handler
;
64 sa
.sa_flags
= SA_RESTART
;
65 if (sigfillset(&sa
.sa_mask
)) {
69 if (sigaction(SIGINT
, &sa
, NULL
)) {
74 door_server_create(create_door_thread
);
76 if ((did
= door_create(server_procedure
, NULL
, 0)) < 0) {
77 perror("door_create");
81 /* Let the server thread to run. */
84 /* Send a signal to the server thread that should be already created and
85 blocked in door_return. */
86 if (_lwp_kill(server_lwpid
, SIGINT
)) {
91 /* Let the other thread to run. */
97 if (did
>= 0 && door_revoke(did
))
98 perror("door_revoke");