[Cluster-devel] [PATCH] glocktop: Fix a tight loop under nohup
Bob Peterson
rpeterso at redhat.com
Fri Feb 26 19:57:53 UTC 2016
----- Original Message -----
> When glocktop is run under nohup, it redirects /dev/null to stdin, which
> flags up EOF and causes the file descriptor to always be in a ready
> state when select()ed. This causes select() to return immediately
> instead of timing out after the refresh delay.
>
> Make sure to sleep for the refresh delay on EOF to avoid getting into a
> tight loop when running under nohup.
>
> Signed-off-by: Andrew Price <anprice at redhat.com>
> ---
> gfs2/glocktop/glocktop.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
> index 43c3c3f..fe6bcc2 100644
> --- a/gfs2/glocktop/glocktop.c
> +++ b/gfs2/glocktop/glocktop.c
> @@ -1856,6 +1856,15 @@ int main(int argc, char **argv)
> if (refresh_time < 1)
> refresh_time = 1;
> break;
> + /* We can get an EOF if the user hits ^D or if
> + /dev/null is redirected to stdin, such as when
> + running under nohup. It should be safe to assume the
> + latter since ^D shouldn't be expected to do anything
> + useful. In that case, select() returns immediately
> + so we need to enforce the refresh delay with a sleep */
> + case EOF:
> + sleep(refresh_time);
> + break;
> }
> }
> iters_done++;
> --
> 2.4.3
>
>
ACK
Bob Peterson
More information about the Cluster-devel
mailing list