[PATCH 3/4] selftests: ublk: kublk: ignore SIGCHLD

Uday Shankar posted 4 patches 8 months, 4 weeks ago
[PATCH 3/4] selftests: ublk: kublk: ignore SIGCHLD
Posted by Uday Shankar 8 months, 4 weeks ago
SIGCHLD from exiting children can arrive during io_uring_wait_cqe and
cause it to return early with -EINTR. Since we don't have a handler for
SIGCHLD, avoid this issue by ignoring SIGCHLD.

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
---
 tools/testing/selftests/ublk/kublk.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c
index ded1b93e7913011499ae5dae7b40f0e425982ee4..064a5bb6f12f35892065b8dfacb6f57f6fc16aee 100644
--- a/tools/testing/selftests/ublk/kublk.c
+++ b/tools/testing/selftests/ublk/kublk.c
@@ -890,6 +890,7 @@ static int cmd_dev_add(struct dev_ctx *ctx)
 		exit(-1);
 	}
 
+	signal(SIGCHLD, SIG_IGN);
 	setsid();
 	res = fork();
 	if (res == 0) {

-- 
2.34.1
Re: [PATCH 3/4] selftests: ublk: kublk: ignore SIGCHLD
Posted by Ming Lei 8 months, 4 weeks ago
On Tue, Mar 25, 2025 at 04:19:33PM -0600, Uday Shankar wrote:
> SIGCHLD from exiting children can arrive during io_uring_wait_cqe and
> cause it to return early with -EINTR. Since we don't have a handler for

Probably -EINTR needs to be handled, and libublksrv retry in case of -EINTR.

> SIGCHLD, avoid this issue by ignoring SIGCHLD.
> 
> Signed-off-by: Uday Shankar <ushankar@purestorage.com>
> ---
>  tools/testing/selftests/ublk/kublk.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c
> index ded1b93e7913011499ae5dae7b40f0e425982ee4..064a5bb6f12f35892065b8dfacb6f57f6fc16aee 100644
> --- a/tools/testing/selftests/ublk/kublk.c
> +++ b/tools/testing/selftests/ublk/kublk.c
> @@ -890,6 +890,7 @@ static int cmd_dev_add(struct dev_ctx *ctx)
>  		exit(-1);
>  	}
>  
> +	signal(SIGCHLD, SIG_IGN);

Reviewed-by: Ming Lei <ming.lei@redhat.com>

BTW, the SIGCHLD signal is ignored by default, looks it is good
to do it explicitly, if the -EINTR from io_uring_enter() can be avoided
in this way.


Thanks,
Ming
Re: [PATCH 3/4] selftests: ublk: kublk: ignore SIGCHLD
Posted by Uday Shankar 8 months, 3 weeks ago
On Wed, Mar 26, 2025 at 11:23:25AM +0800, Ming Lei wrote:
> BTW, the SIGCHLD signal is ignored by default

You're right, that's a good point, this change is actually a noop. I
think I got confused during test development and the -EINTR probably
came from something else. I see no issues when reverting this change in
my tests now, so I will drop it.