[LTP] [PATCH v2 1/3] syscalls/tgkill01: add new test

Cyril Hrubis chrubis@suse.cz
Thu Mar 14 14:58:37 CET 2019


Hi!
> I am not sure how we would manage actual "msec_timeout" in case we get
> EINTR and need to retry again as we may need to take care of elapsed
> time till we receive asynchronous signal.

I would have just restarted the timeout after we got signal, the worst case
that can happen is that in an unlikely case we will send a signals fast enough
so that the checkpoint will never timeout. But even then the test library will
timeout and would kill the process anyways.

Another option is to switch checkpoints so that they use absolute timeout and
pass clock_gettime() + msec_timeout as timeout.

I would go for something as simple as:

diff --git a/lib/tst_checkpoint.c b/lib/tst_checkpoint.c
index 5455d0378..5e5b11496 100644
--- a/lib/tst_checkpoint.c
+++ b/lib/tst_checkpoint.c
@@ -85,6 +85,7 @@ void tst_checkpoint_init(const char *file, const int lineno,
 int tst_checkpoint_wait(unsigned int id, unsigned int msec_timeout)
 {
        struct timespec timeout;
+       int ret;
 
        if (id >= tst_max_futexes) {
                errno = EOVERFLOW;
@@ -94,8 +95,12 @@ int tst_checkpoint_wait(unsigned int id, unsigned int msec_timeout)
        timeout.tv_sec = msec_timeout/1000;
        timeout.tv_nsec = (msec_timeout%1000) * 1000000;
 
-       return syscall(SYS_futex, &tst_futexes[id], FUTEX_WAIT,
-                      tst_futexes[id], &timeout);
+       do {
+               ret = syscall(SYS_futex, &tst_futexes[id], FUTEX_WAIT,
+                             tst_futexes[id], &timeout);
+       } while (ret == -1 && errno == EINTR);
+
+       return ret;
 }

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list