Skip to content

Commit

Permalink
Merge pull request #4319 from lifubang/fix-execfifo-delete-error
Browse files Browse the repository at this point in the history
Try to delete exec fifo file when failure in creation
  • Loading branch information
kolyshkin committed Jun 26, 2024
2 parents 213fefd + e729452 commit ab010ae
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 @@ -411,7 +411,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 @@ -425,6 +425,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 ab010ae

Please sign in to comment.