Pi66

sta
minimal & simple status monitoring app.
git clone https://git.pi66.xyz/sta

← back to log

fix: check unlink() and cleanup on exit

author: pi66
date: 2026-05-21 18:59
hash: 4bad46c0df6076b5feea728ff6f662053e7e9f46

Diffstat:

M

sta.c
3 ++++++++++++++++++++++++++++++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/sta.c b/sta.c
index 3e4b66b..36a11d2 100644
--- a/sta.c
+++ b/sta.c
@@ -226,6 +226,8 @@ int main(int argc, char const *argv[])
                      die("Socket: socket exists and connectable.");        
                  close(checking_sock);
                }
+           if (unlink(SOCKET_PATH) == -1)
+             die("Socket: socket clean up failed.");
            }
            run_server(&addr, sock, list);
        }
@@ -238,5 +240,6 @@ int main(int argc, char const *argv[])
    }

    close(sock);
+   unlink(SOCKET_PATH);
    return 0;
 }