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>
This commit is contained in:
parent
37477794b2
commit
bd65ce1010
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue