[PATCH xorg-gtest 2/4] process: if termination fails, the state must not be TERMINATED

Chase Douglas chase.douglas at ubuntu.com
Tue Oct 9 08:28:02 PDT 2012


On Sun, Oct 7, 2012 at 7:46 PM, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> If a process is hung and doesn't respond to termination, a Kill() call must
> still try to actually kill the process. In the current code, unsuccessful
> termination would still set the state, preventing Kill() from actually
> working
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  src/process.cpp | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/src/process.cpp b/src/process.cpp
> index 555e56b..abd107d 100644
> --- a/src/process.cpp
> +++ b/src/process.cpp
> @@ -158,8 +158,6 @@ bool xorg::testing::Process::WaitForExit(unsigned int timeout) {
>  }
>
>  bool xorg::testing::Process::KillSelf(int signal, unsigned int timeout) {
> -  bool wait_success = true;
> -
>    enum State state = GetState();
>    switch (state) {
>      case FINISHED_SUCCESS:
> @@ -184,12 +182,17 @@ bool xorg::testing::Process::KillSelf(int signal, unsigned int timeout) {
>        d_->state = ERROR;
>        return false;
>      }
> -    if (timeout > 0)
> +    if (timeout > 0) {
> +      bool wait_success = true;
> +
>        wait_success = WaitForExit(timeout);
> +      if (!wait_success)
> +        return false;
> +    }
>      d_->pid = -1;
>    }
>    d_->state = TERMINATED;
> -  return wait_success;
> +  return true;
>  }
>
>  bool xorg::testing::Process::Terminate(unsigned int timeout) {

This fix looks good.

For this and the following two related patches:

Reviewed-by: Chase Douglas <chase.douglas at ubuntu.com>


More information about the xorg-devel mailing list