Debugging threads with HP Wilde Beest

fatal_error(return_val, msg); \
}
main()
{
pthread_t tid1, tid2, tid3;
int ret_val;
/* Create two threads to do the work */
ret_val = pthread_create(&tid1, (pthread_attr_t *)NULL,
(void *(*)())my_thread, (void *)1);
check_error(ret_val, "pthread_create 1 failed");
ret_val = pthread_create(&tid2, (pthread_attr_t *)NULL,
(void *(*)())my_thread, (void *)2);
check_error(ret_val, "pthread_create 2 failed");
ret_val = pthread_create(&tid3, (pthread_attr_t *)NULL,
(void *(*)())my_thread, (void *)3);
check_error(ret_val, "pthread_create 3 failed");
/* Detach thread 1 */
ret_val = pthread_detach(tid1);
check_error(ret_val, "pthread_join: tid");
sleep(5);
/* Wait for the thread 2 to finishes */
ret_val = pthread_join(tid2, (void **)NULL);
check_error(ret_val, "pthread_join: tid");
exit(0);
}
void
fatal_error(int err_num, char *function)
{
char *err_string;
err_string = strerror(err_num);
fprintf(stderr, "%s error: %s\n", function, err_string);
exit(-1);
}
If an application repeatedly created threads without the join or detach operation, it
will leak resources that might eventually cause the application to fail.
The following command enables you to check this condition in a threaded application:
set thread-check thread-exit-no-join-detach[on|off]
In such a scenario, the debugger transfers the execution control to the user and displays
a warning message.
The following is a segment of the HP WDB output:
34