Try for a configurable time and quit
Hi, am writing a C++ program that needs to execute a function, provided with a lib, that may hang resulting in the whole thread getting stuck. If I want to say wait for only a few seconds and then move on, is there a way to do this? Thanks.
|
Quote:
now that sounds like a strange library function! Why does it behave like that? Is that really within its specification? Anyway: You could create a new thread (man pthread_create), call that weird library function in that (using your own wrapper function), and monitor how that goes from your main thread. But to me, that sounds like a lot of work for just calling a library function... Regards dmdeb |
Some example code for that (hanger.c):
Code:
#include <assert.h> Code:
CFLAGS=-W -Wall -Werror -pedantic |
All times are GMT -5. The time now is 03:16 PM. |