From a6c7265aa68fca3a5023ad2b399799db583fffeb Mon Sep 17 00:00:00 2001
From: zhangsong <zhangsong34@huawei.com>
Date: Tue, 14 Jun 2022 10:25:47 +0800
Subject: [PATCH] containerd: put get pid lock after set process exited to avoid
 deadlock.

Signed-off-by: zhangsong <zhangsong34@huawei.com>
---
 runtime/v1/linux/proc/exec.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/runtime/v1/linux/proc/exec.go b/runtime/v1/linux/proc/exec.go
index a5f40bd..ff967b5 100644
--- a/runtime/v1/linux/proc/exec.go
+++ b/runtime/v1/linux/proc/exec.go
@@ -86,14 +86,14 @@ func (e *execProcess) ExitedAt() time.Time {
 }
 
 func (e *execProcess) SetExited(status int) {
-	e.pid.Lock()
-	e.pid.pid = -1
-	e.pid.Unlock()
-
 	e.mu.Lock()
 	defer e.mu.Unlock()
 
 	e.execState.SetExited(status)
+
+	e.pid.Lock()
+	e.pid.pid = -1
+	e.pid.Unlock()
 }
 
 func (e *execProcess) setExited(status int) {
-- 
2.27.0

