Skip to content

Commit e729452

Browse files
committed
try to delete exec fifo file when failure in creation
Signed-off-by: lifubang <[email protected]>
1 parent 349e5ab commit e729452

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libcontainer/container_linux.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ func (c *Container) Signal(s os.Signal) error {
406406
return nil
407407
}
408408

409-
func (c *Container) createExecFifo() error {
409+
func (c *Container) createExecFifo() (retErr error) {
410410
rootuid, err := c.Config().HostRootUID()
411411
if err != nil {
412412
return err
@@ -423,6 +423,11 @@ func (c *Container) createExecFifo() error {
423423
if err := unix.Mkfifo(fifoName, 0o622); err != nil {
424424
return &os.PathError{Op: "mkfifo", Path: fifoName, Err: err}
425425
}
426+
defer func() {
427+
if retErr != nil {
428+
os.Remove(fifoName)
429+
}
430+
}()
426431
// Ensure permission bits (can be different because of umask).
427432
if err := os.Chmod(fifoName, 0o622); err != nil {
428433
return err

0 commit comments

Comments
 (0)