Skip to content
Snippets Groups Projects
Commit 0b0d958b authored by Guillaume J. Charmes's avatar Guillaume J. Charmes
Browse files

Merge pull request #463 from dotcloud/improve_pid_file_feature

Check that the pid in pidfile exists before preventing docker to start
parents 03e4704a f079fbe3
No related branches found
No related tags found
No related merge requests found
......@@ -7,9 +7,11 @@ import (
"github.com/dotcloud/docker/rcli"
"github.com/dotcloud/docker/term"
"io"
"io/ioutil"
"log"
"os"
"os/signal"
"strconv"
"syscall"
)
......@@ -54,8 +56,13 @@ func main() {
}
func createPidFile(pidfile string) error {
if _, err := os.Stat(pidfile); err == nil {
return fmt.Errorf("pid file found, ensure docker is not running or delete %s", pidfile)
if pidString, err := ioutil.ReadFile(pidfile); err == nil {
pid, err := strconv.Atoi(string(pidString))
if err == nil {
if _, err := os.Stat(fmt.Sprintf("/proc/%d/", pid)); err == nil {
return fmt.Errorf("pid file found, ensure docker is not running or delete %s", pidfile)
}
}
}
file, err := os.Create(pidfile)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment