[lxc-devel] [crio-lxc/master] create: actually create a pidfile
hallyn on Github
lxc-bot at linuxcontainers.org
Mon Apr 22 19:15:19 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 379 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190422/5f4fa40b/attachment.bin>
-------------- next part --------------
From 1db3c17b6dd8f6d94744caa7b1bb6ec0c453e130 Mon Sep 17 00:00:00 2001
From: Serge Hallyn <shallyn at cisco.com>
Date: Mon, 22 Apr 2019 19:12:37 +0000
Subject: [PATCH] create: actually create a pidfile
Else conmon is not happy.
Signed-off-by: Serge Hallyn <shallyn at cisco.com>
---
cmd/create.go | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/cmd/create.go b/cmd/create.go
index 1b9d73d..613a51b 100644
--- a/cmd/create.go
+++ b/cmd/create.go
@@ -81,6 +81,7 @@ exec $@
}
func doCreate(ctx *cli.Context) error {
+ pidfile := ctx.String("pid-file")
containerID := ctx.Args().Get(0)
if len(containerID) == 0 {
fmt.Fprintf(os.Stderr, "missing container ID\n")
@@ -125,6 +126,13 @@ func doCreate(ctx *cli.Context) error {
return errors.Wrap(err, "failed to start the container init")
}
+ if pidfile != "" {
+ err := ioutil.WriteFile(pidfile, []byte(fmt.Sprintf("%d", c.InitPid())), 0755)
+ if err != nil {
+ return errors.Wrapf(err, "Couldn't create pid file %s", pidfile)
+ }
+ }
+
log.Infof("created container %s in lxcdir %s", containerID, LXC_PATH)
return nil
}
More information about the lxc-devel
mailing list