aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-05-24 15:26:28 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-05-24 15:29:15 +0200
commitccb8e4bc4fb74701d0d323d61e9359d8597a4272 (patch)
treeebab2c7ac66d99102978efa66045d33abfb16341
parent8c24af9dcfe0d89a660c39838eec4d20bc13efbf (diff)
downloadbusybox-w32-ccb8e4bc4fb74701d0d323d61e9359d8597a4272.tar.gz
busybox-w32-ccb8e4bc4fb74701d0d323d61e9359d8597a4272.tar.bz2
busybox-w32-ccb8e4bc4fb74701d0d323d61e9359d8597a4272.zip
fsck: fix incorrect handling of child exit
In commit c4fb8c6a - fsck: do not use statics not only statics were changed but also a couple of statics-unrelated changes were made. This included the handling of the child termination status as follows: - if (WIFEXITED(status)) - status = WEXITSTATUS(status); - else if (WIFSIGNALED(status)) { + status = WEXITSTATUS(status); + if (WIFSIGNALED(status)) { This is wrong, should have used a different variable to hold exit code. Reported by Niklas Hambüchen <mail@nh2.me>. function old new delta wait_one 294 282 -12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--e2fsprogs/fsck.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c
index 1c285bb92..f5aa3dbe4 100644
--- a/e2fsprogs/fsck.c
+++ b/e2fsprogs/fsck.c
@@ -414,7 +414,7 @@ static void kill_all_if_got_signal(void)
414static int wait_one(int flags) 414static int wait_one(int flags)
415{ 415{
416 int status; 416 int status;
417 int sig; 417 int exitcode;
418 struct fsck_instance *inst, *prev; 418 struct fsck_instance *inst, *prev;
419 pid_t pid; 419 pid_t pid;
420 420
@@ -448,15 +448,16 @@ static int wait_one(int flags)
448 } 448 }
449 child_died: 449 child_died:
450 450
451 status = WEXITSTATUS(status); 451 exitcode = WEXITSTATUS(status);
452 if (WIFSIGNALED(status)) { 452 if (WIFSIGNALED(status)) {
453 unsigned sig;
453 sig = WTERMSIG(status); 454 sig = WTERMSIG(status);
454 status = EXIT_UNCORRECTED; 455 exitcode = EXIT_UNCORRECTED;
455 if (sig != SIGINT) { 456 if (sig != SIGINT) {
456 printf("Warning: %s %s terminated " 457 printf("Warning: %s %s terminated "
457 "by signal %d\n", 458 "by signal %u\n",
458 inst->prog, inst->device, sig); 459 inst->prog, inst->device, sig);
459 status = EXIT_ERROR; 460 exitcode = EXIT_ERROR;
460 } 461 }
461 } 462 }
462 463
@@ -492,12 +493,12 @@ static int wait_one(int flags)
492 else 493 else
493 G.instance_list = inst->next; 494 G.instance_list = inst->next;
494 if (G.verbose > 1) 495 if (G.verbose > 1)
495 printf("Finished with %s (exit status %d)\n", 496 printf("Finished with %s (exit status %u)\n",
496 inst->device, status); 497 inst->device, exitcode);
497 G.num_running--; 498 G.num_running--;
498 free_instance(inst); 499 free_instance(inst);
499 500
500 return status; 501 return exitcode;
501} 502}
502 503
503/* 504/*