iowait example plugin should remove the socket when done

This commit is contained in:
Paul Bellamy
2016-04-12 15:55:27 +01:00
parent 4b4e52397b
commit 72518e7036
2 changed files with 10 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"os"
"os/exec"
"os/signal"
"strconv"
"strings"
"time"
@@ -31,6 +32,14 @@ func main() {
}
os.Remove(*addr)
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
go func() {
<-interrupt
os.Remove(*addr)
os.Exit(0)
}()
listener, err := net.Listen("unix", *addr)
if err != nil {
log.Fatal(err)