partage

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.z3bra.org/partage.git
Log | Files | Refs | README | LICENSE

commit cc5de454d8290ffeb896746714ab169ba4c5e15c
parent 3fbec63ccb26b91c113e6f9b4f423682b0e079e4
Author: Willy Goiffon <dev@z3bra.org>
Date:   Tue, 19 Oct 2021 23:13:18 +0200

Remove unix socket on termination

Diffstat:
Mpartage.go | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/partage.go b/partage.go @@ -12,6 +12,7 @@ import ( "net/http" "net/http/fcgi" "os" + "os/signal" "os/user" "path" "path/filepath" @@ -327,7 +328,16 @@ func main() { if err != nil { log.Fatal(err) } + + /* Ensure unix socket is removed on exit */ 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 { listener, err = net.Listen("tcp", conf.bind) if err != nil {