Remove unix socket on termination
git-svn-id: file:///srv/svn/repo/marisa/trunk@42 d6811dac-2434-b64a-9ddc-f563ab233461
This commit is contained in:
10
partage.go
10
partage.go
@@ -12,6 +12,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/fcgi"
|
"net/http/fcgi"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -327,7 +328,16 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure unix socket is removed on exit */
|
||||||
defer os.Remove(conf.bind)
|
defer os.Remove(conf.bind)
|
||||||
|
sigs := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
go func() {
|
||||||
|
_ = <-sigs
|
||||||
|
os.Remove(conf.bind)
|
||||||
|
os.Exit(0)
|
||||||
|
}()
|
||||||
} else {
|
} else {
|
||||||
listener, err = net.Listen("tcp", conf.bind)
|
listener, err = net.Listen("tcp", conf.bind)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user