|
|
2de1a8 |
From c6ea93fcb499c84c3d8e9aad2ced65065a3f6d51 Mon Sep 17 00:00:00 2001
|
|
|
2de1a8 |
From: Fujii Masao <fujii@postgresql.org>
|
|
|
2de1a8 |
Date: Tue, 19 Jul 2022 22:34:08 +0900
|
|
|
2de1a8 |
Subject: [PATCH] Fix bug in handling of child process exit.
|
|
|
2de1a8 |
|
|
|
2de1a8 |
When storage_mon detects that a child process exits with zero,
|
|
|
2de1a8 |
it resets the test_forks[] entry for the child process to 0, to avoid
|
|
|
2de1a8 |
waitpid() for the process again in the loop. But, previously,
|
|
|
2de1a8 |
storage_mon didn't do that when it detected that a child process
|
|
|
2de1a8 |
exited with non-zero. Which caused waitpid() to be called again
|
|
|
2de1a8 |
for the process already gone and to report an error like
|
|
|
2de1a8 |
"waitpid on XXX failed: No child processes" unexpectedly.
|
|
|
2de1a8 |
In this case, basically storage_mon should wait until all the child
|
|
|
2de1a8 |
processes exit and return the final score, instead.
|
|
|
2de1a8 |
|
|
|
2de1a8 |
This patch fixes this issue by making storage_mon reset test_works[]
|
|
|
2de1a8 |
entry even when a child process exits with non-zero.
|
|
|
2de1a8 |
---
|
|
|
2de1a8 |
tools/storage_mon.c | 8 ++++----
|
|
|
2de1a8 |
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
2de1a8 |
|
|
|
2de1a8 |
diff --git a/tools/storage_mon.c b/tools/storage_mon.c
|
|
|
2de1a8 |
index 3c82d5ee8..83a48ca36 100644
|
|
|
2de1a8 |
--- a/tools/storage_mon.c
|
|
|
2de1a8 |
+++ b/tools/storage_mon.c
|
|
|
2de1a8 |
@@ -232,13 +232,13 @@ int main(int argc, char *argv[])
|
|
|
2de1a8 |
|
|
|
2de1a8 |
if (w == test_forks[i]) {
|
|
|
2de1a8 |
if (WIFEXITED(wstatus)) {
|
|
|
2de1a8 |
- if (WEXITSTATUS(wstatus) == 0) {
|
|
|
2de1a8 |
- finished_count++;
|
|
|
2de1a8 |
- test_forks[i] = 0;
|
|
|
2de1a8 |
- } else {
|
|
|
2de1a8 |
+ if (WEXITSTATUS(wstatus) != 0) {
|
|
|
2de1a8 |
syslog(LOG_ERR, "Error reading from device %s", devices[i]);
|
|
|
2de1a8 |
final_score += scores[i];
|
|
|
2de1a8 |
}
|
|
|
2de1a8 |
+
|
|
|
2de1a8 |
+ finished_count++;
|
|
|
2de1a8 |
+ test_forks[i] = 0;
|
|
|
2de1a8 |
}
|
|
|
2de1a8 |
}
|
|
|
2de1a8 |
}
|