From 6067787685ca8988c3894deb13c31d68fd794cc0 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sat, 28 Sep 2024 01:39:52 +0900 Subject: [PATCH] tests: (test_mkfds) save errno before calling system calls for clean-up Signed-off-by: Masatake YAMATO --- tests/helpers/test_mkfds.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/helpers/test_mkfds.c b/tests/helpers/test_mkfds.c index 5b009bb6f..38c39292c 100644 --- a/tests/helpers/test_mkfds.c +++ b/tests/helpers/test_mkfds.c @@ -2519,7 +2519,9 @@ static void *make_mqueue(const struct factory *factory, struct fdesc fdescs[], fd = mq_open(mqueue_data->path, O_CREAT|O_EXCL | O_RDONLY, S_IRUSR | S_IWUSR, &attr); if (fd < 0) { + int e = errno; mqueue_data_free(mqueue_data); + errno = e; err(EXIT_FAILURE, "failed in mq_open(3) for reading"); } @@ -2599,8 +2601,10 @@ static void *make_mqueue(const struct factory *factory, struct fdesc fdescs[], /* Wait till the child is ready. */ if (mq_receive(fdescs[0].fd, &c, 1, NULL) < 0) { + int e = errno; mq_close(fdescs[0].fd); mqueue_data_free(mqueue_data); + errno = e; err(EXIT_FAILURE, "failed in mq_receive() the readiness notification from the child"); } -- 2.47.3