[lxc-devel] [lxd/master] shared/subprocess: Fix Stop handling
stgraber on Github
lxc-bot at linuxcontainers.org
Wed May 27 02:07:05 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200526/276f0d65/attachment.bin>
-------------- next part --------------
From 0017346306c917cfc93035dc6382a917d17ed437 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 26 May 2020 20:54:32 -0400
Subject: [PATCH] shared/subprocess: Fix Stop handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
shared/subprocess/proc.go | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/shared/subprocess/proc.go b/shared/subprocess/proc.go
index b5caf41068..2ca1eca9a9 100644
--- a/shared/subprocess/proc.go
+++ b/shared/subprocess/proc.go
@@ -47,16 +47,20 @@ func (p *Process) Stop() error {
if err == nil {
err = pr.Kill()
if err == nil {
+ if p.hasMonitor {
+ <-p.chExit
+ }
+
return nil // Killed successfully.
}
}
- if p.hasMonitor {
- <-p.chExit
- }
-
// Check if either the existence check or the kill resulted in an already finished error.
if strings.Contains(err.Error(), "process already finished") {
+ if p.hasMonitor {
+ <-p.chExit
+ }
+
return ErrNotRunning
}
More information about the lxc-devel
mailing list