tRemove unix socket on termination - partage - File upload system
 (HTM) git clone git://git.z3bra.org/partage.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit cc5de454d8290ffeb896746714ab169ba4c5e15c
 (DIR) parent 3fbec63ccb26b91c113e6f9b4f423682b0e079e4
 (HTM) Author: Willy Goiffon <dev@z3bra.org>
       Date:   Tue, 19 Oct 2021 23:13:18 +0200
       
       Remove unix socket on termination
       
       Diffstat:
         M partage.go                          |      10 ++++++++++
       
       1 file changed, 10 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/partage.go b/partage.go
       t@@ -12,6 +12,7 @@ import (
                "net/http"
                "net/http/fcgi"
                "os"
       +        "os/signal"
                "os/user"
                "path"
                "path/filepath"
       t@@ -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 {