代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/docker 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From f70a2648621ab1463299eabecda8e8c7584831c3 Mon Sep 17 00:00:00 2001
From: jingrui <jingrui@huawei.com>
Date: Thu, 3 Jan 2019 16:01:36 +0800
Subject: [PATCH 043/111] docker: Make sure the pid exist in pidfile
is docker
reason: cherry-pick commits to docker-18.09.
cherry-pick from
b4714e3321 | * Make sure the pid exist in pidfile is docker
Because of the recycling of used PIDs policy in kernel,
it could be possible that the process died with pidfile existing
and when the process boot next time, the pid in pidfile has been assigned
to another process, this would make the process can't be boot again without
removing the pidfile manually.
Change-Id: I237566682716733174900cd4dc76ce74ff9f4195
Signed-off-by: Lei Jitang <leijitang@huawei.com>
Signed-off-by: jingrui <jingrui@huawei.com>
---
components/engine/pkg/pidfile/pidfile.go | 30 +++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/components/engine/pkg/pidfile/pidfile.go b/components/engine/pkg/pidfile/pidfile.go
index 0617a89e5f..485c00138b 100644
--- a/components/engine/pkg/pidfile/pidfile.go
+++ b/components/engine/pkg/pidfile/pidfile.go
@@ -4,6 +4,7 @@
package pidfile // import "github.com/docker/docker/pkg/pidfile"
import (
+ "bufio"
"fmt"
"io/ioutil"
"os"
@@ -19,12 +20,39 @@ type PIDFile struct {
path string
}
+// isSameApplication check whether the pid exist in pidfile
+// is the the same application we are going to run.
+func isSameApplication(pid int) (bool, error) {
+ path := filepath.Join("/proc", strconv.Itoa(pid), "status")
+ file, err := os.Open(path)
+ if err != nil {
+ return false, err
+ }
+ defer file.Close()
+ sc := bufio.NewScanner(file)
+ for sc.Scan() {
+ lens := strings.Split(sc.Text(), ":")
+ if len(lens) == 2 && strings.TrimSpace(lens[0]) == "Name" {
+ if strings.TrimSpace(lens[1]) == os.Args[0] {
+ return true, nil
+ }
+ return false, nil
+ }
+ }
+ if err := sc.Err(); err != nil {
+ return false, err
+ }
+ return false, nil
+}
+
func checkPIDFileAlreadyExists(path string) error {
if pidByte, err := ioutil.ReadFile(path); err == nil {
pidString := strings.TrimSpace(string(pidByte))
if pid, err := strconv.Atoi(pidString); err == nil {
if processExists(pid) {
- return fmt.Errorf("pid file found, ensure docker is not running or delete %s", path)
+ if same, err := isSameApplication(pid); same || (err != nil && !os.IsNotExist(err)) {
+ return fmt.Errorf("pid file found, ensure docker is not running or delete %s", path)
+ }
}
}
}
--
2.17.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。