lkml.org 
[lkml]   [2019]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()
Date
From: Deepa Dinamani
> Sent: 24 May 2019 18:02
...
> Maybe a crude userspace application could do something like this:
>
> sig_handler()
> {
> set global abort = 1
> }
>
> poll_the_fds()
> {
> ret = epoll_pwait()
> if (ret)
> return ret
> if (abort)
> // but this abort should be ignored if ret was 0.
> return try_again
>
> }

As an application writer I'd want to see 'abort == 1' even
if epoll_pwait() returned that an fd was 'ready'.

So the code above should probably be:
wait_again:
ret = epoll_pwait();
if (abort)
process_abort();
if (ret <= 0) {
if (ret == 0)
process_timeout();
if (ret == 0 || errno == EINTR)
goto wait_again;
// Something went horribly wrong in epoll_pwait()
return ret;
}
// process the 'ready' fds

It would be non-unreasonable for the application to have
all signals blocked except during the epoll_pwait().
So the application needs the signal handler for SIG_INT (etc)
to be called even if one of the fd is always 'ready'.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
\
 
 \ /
  Last update: 2019-05-28 11:03    [W:0.171 / U:1.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site