Skip to content

Commit

Permalink
try to delete exec fifo file when failure in creation
Browse files Browse the repository at this point in the history
Signed-off-by: lifubang <lifubang@acmcoder.com>
  • Loading branch information
lifubang committed Jun 10, 2024
1 parent 349e5ab commit e729452
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func (c *Container) Signal(s os.Signal) error {
return nil
}

func (c *Container) createExecFifo() error {
func (c *Container) createExecFifo() (retErr error) {
rootuid, err := c.Config().HostRootUID()
if err != nil {
return err
Expand All @@ -423,6 +423,11 @@ func (c *Container) createExecFifo() error {
if err := unix.Mkfifo(fifoName, 0o622); err != nil {
return &os.PathError{Op: "mkfifo", Path: fifoName, Err: err}
}
defer func() {
if retErr != nil {
os.Remove(fifoName)
}
}()
// Ensure permission bits (can be different because of umask).
if err := os.Chmod(fifoName, 0o622); err != nil {
return err
Expand Down

0 comments on commit e729452

Please sign in to comment.