]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - keydb_keyd.c
Make keyd background itself by default
[onak.git] / keydb_keyd.c
index 3f199bd8c09d319c66344a8f842fdb1fa39a0971..35d2dc4cab504d388a5e2d3e7bcd4cd693c6fa93 100644 (file)
@@ -103,10 +103,23 @@ static void keyd_initdb(bool readonly)
  */
 static void keyd_cleanupdb(void)
 {
+       int cmd = KEYD_CMD_CLOSE;
+
+       if (write(keyd_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) {
+               logthing(LOGTHING_CRITICAL,
+                               "Couldn't send close cmd: %s (%d)",
+                               strerror(errno),
+                               errno);
+       }
+
        if (shutdown(keyd_fd, SHUT_RDWR) < 0) {
                logthing(LOGTHING_NOTICE, "Error shutting down socket: %d",
                                errno);
        }
+       if (close(keyd_fd) < 0) {
+               logthing(LOGTHING_NOTICE, "Error closing down socket: %d",
+                               errno);
+       }
        keyd_fd = -1;
 
        return;