Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -7,8 +7,11 @@ import ( |
| 7 | 7 |
"fmt" |
| 8 | 8 |
"io/ioutil" |
| 9 | 9 |
"os" |
| 10 |
+ "path/filepath" |
|
| 10 | 11 |
"strconv" |
| 11 | 12 |
"strings" |
| 13 |
+ |
|
| 14 |
+ "github.com/docker/docker/pkg/system" |
|
| 12 | 15 |
) |
| 13 | 16 |
|
| 14 | 17 |
// PIDFile is a file used to store the process ID of a running process. |
| ... | ... |
@@ -33,6 +36,10 @@ func New(path string) (*PIDFile, error) {
|
| 33 | 33 |
if err := checkPIDFileAlreadyExists(path); err != nil {
|
| 34 | 34 |
return nil, err |
| 35 | 35 |
} |
| 36 |
+ // Note MkdirAll returns nil if a directory already exists |
|
| 37 |
+ if err := system.MkdirAll(filepath.Dir(path), os.FileMode(0755)); err != nil {
|
|
| 38 |
+ return nil, err |
|
| 39 |
+ } |
|
| 36 | 40 |
if err := ioutil.WriteFile(path, []byte(fmt.Sprintf("%d", os.Getpid())), 0644); err != nil {
|
| 37 | 41 |
return nil, err |
| 38 | 42 |
} |