aboutsummaryrefslogtreecommitdiffstats
path: root/lib/socket.go
diff options
context:
space:
mode:
authorMoritz Poldrack <git@moritz.sh>2022-02-25 16:03:43 +0100
committerRobin Jarry <robin@jarry.cc>2022-03-03 21:10:56 +0100
commitbd65ce1010a78eec38ba9c70d9fc23f85cd087a1 (patch)
tree34ae8ccb4c80fdbbe288b4e81f84a84d7296e6c5 /lib/socket.go
parent37477794b229b9ea240cd85b226eefc442033354 (diff)
downloadaerc-bd65ce1010a78eec38ba9c70d9fc23f85cd087a1.tar.gz
add removal of existing sockets
The kept socket after crashes or unclean exits can lead to a unexpected behaviour. This commit just removes dangling sockets if they exist. Since the "does not exist" error is the best case scenario error handling was deemed unnecessary. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/socket.go')
-rw-r--r--lib/socket.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/socket.go b/lib/socket.go
index cdf0f737..119ffdad 100644
--- a/lib/socket.go
+++ b/lib/socket.go
@@ -7,6 +7,7 @@ import (
"log"
"net"
"net/url"
+ "os"
"path"
"strings"
"sync/atomic"
@@ -23,6 +24,8 @@ type AercServer struct {
func StartServer(logger *log.Logger) (*AercServer, error) {
sockpath := path.Join(xdg.RuntimeDir(), "aerc.sock")
+ // remove the socket if it already exists
+ os.Remove(sockpath)
l, err := net.Listen("unix", sockpath)
if err != nil {
return nil, err