From: anton Date: Tue, 10 Oct 2023 18:18:05 +0000 (+0000) Subject: Fix timing issue in which one thread could be left hanging in X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=dcab91281821c69b4f0f4be3f497e3427a39a2b9;p=openbsd Fix timing issue in which one thread could be left hanging in pipe_read(). --- diff --git a/regress/sys/kern/pipe/test-kqueue.c b/regress/sys/kern/pipe/test-kqueue.c index ede5bc96c88..f13015f8be7 100644 --- a/regress/sys/kern/pipe/test-kqueue.c +++ b/regress/sys/kern/pipe/test-kqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test-kqueue.c,v 1.4 2021/10/22 05:03:57 anton Exp $ */ +/* $OpenBSD: test-kqueue.c,v 1.5 2023/10/10 18:18:05 anton Exp $ */ /* * Copyright (c) 2019 Anton Lindqvist @@ -137,6 +137,8 @@ test_kqueue_write(void) n = read(ctx.c_pipe[0], &c, 1); if (n == -1) err(1, "read"); + if (n == 0) + break; if (n != 1) errx(1, "read: %ld != 1", n); } @@ -296,5 +298,7 @@ kqueue_thread(void *arg) ctx->c_alive = 0; ctx_unlock(ctx); + close(fd); + return NULL; }