diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-08 20:41:34 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-13 21:59:34 -0500 |
commit | ad5ae093f2a22901f51a2133241a02d62d66d9c0 (patch) | |
tree | 096d097d9c622553506e272d5035f134b152530f | |
parent | b7e29d5030d0c766fcd6420d4fdd9a7a4bb4e837 (diff) |
thread_with_stdio: suppress hung task warning
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | lib/thread_with_file.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/thread_with_file.c b/lib/thread_with_file.c index f4946a437332..b09dc60ba628 100644 --- a/lib/thread_with_file.c +++ b/lib/thread_with_file.c @@ -9,6 +9,7 @@ #include <linux/module.h> #include <linux/pagemap.h> #include <linux/poll.h> +#include <linux/sched/sysctl.h> #include <linux/thread_with_file.h> /* stdio_redirect */ @@ -46,7 +47,15 @@ int stdio_redirect_read(struct stdio_redirect *stdio, char *ubuf, size_t len) { struct stdio_buf *buf = &stdio->input; - wait_event(buf->wait, stdio_redirect_has_input(stdio)); + /* + * we're waiting on user input (or for the file descriptor to be + * closed), don't want a hung task warning: + */ + do { + wait_event_timeout(buf->wait, stdio_redirect_has_input(stdio), + sysctl_hung_task_timeout_secs * HZ / 2); + } while (!stdio_redirect_has_input(stdio)); + if (stdio->done) return -1; @@ -67,7 +76,11 @@ int stdio_redirect_readline(struct stdio_redirect *stdio, char *ubuf, size_t len size_t copied = 0; ssize_t ret = 0; again: - wait_event(buf->wait, stdio_redirect_has_input(stdio)); + do { + wait_event_timeout(buf->wait, stdio_redirect_has_input(stdio), + sysctl_hung_task_timeout_secs * HZ / 2); + } while (!stdio_redirect_has_input(stdio)); + if (stdio->done) { ret = -1; goto out; |