From f28fc112e03c3acbdf1a74abecf8676885e892b1 Mon Sep 17 00:00:00 2001 From: Henning Geinitz Date: Sun, 5 May 2002 13:15:49 +0000 Subject: [PATCH] Check return value of waitpid. Don't evaluate status of children if waitpid wasn't successful. Henning Meier-Geinitz --- backend/test.c | 13 +++++++++---- doc/descriptions/test.desc | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/test.c b/backend/test.c index 49afa3bcd..cd0136060 100644 --- a/backend/test.c +++ b/backend/test.c @@ -41,7 +41,7 @@ This backend is for testing frontends. */ -#define BUILD 14 +#define BUILD 15 #include "../include/sane/config.h" @@ -1218,13 +1218,18 @@ finish_pass (Test_Device * test_device) if (test_device->reader_pid > 0) { int status; + int pid; DBG (2, "finish_pass: terminating reader process %d\n", test_device->reader_pid); kill (test_device->reader_pid, SIGTERM); - waitpid (test_device->reader_pid, &status, 0); - - if (WIFEXITED (status)) + pid = waitpid (test_device->reader_pid, &status, 0); + if (pid < 0) + { + DBG (1, "finish_pass: waitpid failed, already terminated? (%s)\n", + strerror (errno)); + } + else if (WIFEXITED (status)) { DBG (2, "finish_pass: reader process terminated with status %s\n", sane_strstatus (WEXITSTATUS (status))); diff --git a/doc/descriptions/test.desc b/doc/descriptions/test.desc index c3fc24e98..667986c3b 100644 --- a/doc/descriptions/test.desc +++ b/doc/descriptions/test.desc @@ -10,7 +10,7 @@ ; :backend "test" ; name of backend -:version "1.0-14" ; version of backend +:version "1.0-15" ; version of backend :status :beta ; :alpha, :beta, :stable, :new :manpage "sane-test" ; name of manpage (if it exists) :url "http://www.meier-geinitz.de/sane/test-backend/" ; backend's web page