aboutsummaryrefslogtreecommitdiff
path: root/shell/shell_common.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-07-02 22:42:47 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-07-02 22:42:47 +0200
commit36ac283682bb176987c0c09e5f8c7e7e96fb1651 (patch)
treedd5e60f44649f1fbd6c6d966b6559bfc7c1b1e62 /shell/shell_common.c
parentbbaa56f7378240fca3db9165dfd02a4504d95ff1 (diff)
downloadbusybox-w32-36ac283682bb176987c0c09e5f8c7e7e96fb1651.tar.gz
busybox-w32-36ac283682bb176987c0c09e5f8c7e7e96fb1651.tar.bz2
busybox-w32-36ac283682bb176987c0c09e5f8c7e7e96fb1651.zip
shell: fix race between signal handlers setting bb_got_signal and poll()
function old new delta __ppoll_time64 - 211 +211 check_got_signal_and_poll - 164 +164 read_key 607 601 -6 shell_builtin_read 1328 1318 -10 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 0/2 up/down: 375/-16) Total: 359 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/shell_common.c')
-rw-r--r--shell/shell_common.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c
index 2baa9d3a8..754fef34b 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -214,12 +214,13 @@ shell_builtin_read(struct builtin_read_params *params)
214 * regardless of SA_RESTART-ness of that signal! 214 * regardless of SA_RESTART-ness of that signal!
215 */ 215 */
216 errno = 0; 216 errno = 0;
217 pfd[0].events = POLLIN; 217 pfd->events = POLLIN;
218//TODO race with a signal arriving just before the poll! 218
219 if (poll(pfd, 1, timeout) <= 0) { 219 /* test bb_got_signal, then poll(), atomically wrt signals */
220 if (check_got_signal_and_poll(pfd, timeout) <= 0) {
220 /* timed out, or some error */ 221 /* timed out, or some error */
221 err = errno; 222 err = errno;
222 if (!err) { 223 if (!err) { /* timed out */
223 retval = (const char *)(uintptr_t)2; 224 retval = (const char *)(uintptr_t)2;
224 break; 225 break;
225 } 226 }