diff options
author | Karel Zak | 2017-04-28 13:25:41 +0200 |
---|---|---|
committer | Karel Zak | 2017-04-28 13:25:41 +0200 |
commit | dc9a23fe66356ece744e27d14bb5fc3368a1a829 (patch) | |
tree | 5a58ce05362e9a257705e2e4f944ecf3e8646b90 | |
parent | Merge branch 'timer' of https://github.com/Villemoes/util-linux (diff) | |
download | kernel-qcow2-util-linux-dc9a23fe66356ece744e27d14bb5fc3368a1a829.tar.gz kernel-qcow2-util-linux-dc9a23fe66356ece744e27d14bb5fc3368a1a829.tar.xz kernel-qcow2-util-linux-dc9a23fe66356ece744e27d14bb5fc3368a1a829.zip |
lib/timer: add comment
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | lib/timer.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/timer.c b/lib/timer.c index 813eade94..210c726cb 100644 --- a/lib/timer.c +++ b/lib/timer.c @@ -10,6 +10,23 @@ #include "c.h" #include "timer.h" +/* + * Note the timeout is used for the first signal, then the signal is send + * repeatedly in interval ~1% of the original timeout to avoid race in signal + * handling -- for example you want to use timer to define timeout for a + * syscall: + * + * setup_timer() + * syscall() + * cancel_timer() + * + * if the timeout is too short than it's possible that the signal is delivered + * before application enter the syscall function. For this reason timer send + * the signal repeatedly. + * + * The applications need to ensure that they can tolerate multiple signal + * deliveries. + */ int setup_timer(timer_t * t_id, struct itimerval *timeout, void (*timeout_handler)(int, siginfo_t *, void *)) { |