Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from c0b/resolve-zombies-in-container
Browse files Browse the repository at this point in the history
loop reaping dead children
  • Loading branch information
codeskyblue committed Jul 15, 2017
2 parents 126c1ba + e83b21e commit ed9230e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions sigchld_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package main

import (
"log"
"os"
"os/signal"
"syscall"
Expand All @@ -23,6 +24,18 @@ func watchChildSignal() {
}

func reapChildren() {
var wstatus syscall.WaitStatus
syscall.Wait4(-1, &wstatus, syscall.WNOHANG, nil)
for {
var wstatus syscall.WaitStatus
wpid, err := syscall.Wait4(-1, &wstatus, syscall.WNOHANG, nil)
if err != nil {
log.Printf("syscall.Wait4 call failed: %v", err)
break
}

if wpid != 0 {
log.Printf("reap dead child: %d, wstatus: %#08x", wpid, wstatus)
} else {
break
}
}
}

0 comments on commit ed9230e

Please sign in to comment.