c - Is it okay to delete a POSIX timer in the event handler function? -


the question

if call create_timer sigev_thread constant stored in sigev_notify field in sigevent structure, when timer event happens, sigev_notify_function callback called.

are there hidden implications or undesirable side-effects calling timer_delete from within callback function?

specific concerns

my initial thought should fine. however, don't understand mechanics operating behind scenes, , i'm concerned there being proper cleanup of callback's thread , handling of signals if timer , it's associated structures removed before handling complete.

background

another user asked this question, says, "do need delete timers after calling timer_create? answer resounding yes. asked follow-up question in comments: "is okay timer callback function?" , didn't have answer that.

it looks in principle not allowed call timer_create or timer_delete, @ least on linux. signal(7) allowing async-signal-safe functions called directly or indirectly signal handler, , strangely timer_create , timer_delete not listed amongst them (perhaps typo , both should listed async-signal-safe, since both timer_create(2) & timer_delete(2) in section 2 of man pages, , appear in syscalls(2))

notice posix signal concepts page not list timer_create possible in signal handler. imagine on operating systems these timer functions might implemented entirely in c library (not in kernel).

my guess (since timer_create , timer_delete syscall on linux listed in <asm/unistd.h>) timer_create , timer_delete in fact async-signal-safe can called linux signal handler. might false on other posix implementations.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -