On Sun, 2005-05-08 at 12:50 +0200, Fons Adriaensen wrote:
On Sun, May 08, 2005 at 12:00:26PM +0200, Jens M
Andreasen wrote:
Can't you use:
void pthread_cleanup_push(void (*routine) (void *), void *arg);
void pthread_cleanup_pop(int execute);
Does the thread still exist as a thread when routine() is called, or more
specific, is routine() called from the thread's own context ? This is not clear
from the man page - routine() could be called from a different thread than
the one that is being cancelled.
The routine() is definately called from the threads own context. A very
common variant is routine() == free() and *arg is some malloced memory
that is only known to this thread.
But this is besides the point. In my original problem it is not the intention
to terminate the thread - just to force the snd_seq_event_input() to return.
The thread could well close the handle, open a new one and continue normal
operation. The simplest solution is probably to send some fake event to the
midi port.
Perhaps poll() with a shortish timeout? Wake up now and then and do some
housekeeping. Otherwise it looks like pthread_kill would or should have
been the one if not for implementation issues (although here I am
uncertain if it isn't so that the documentation of BUGS is outdated for
kernel 2.6?)
--
(
)
c[] // Jens M Andreasen