git: Löschungen werden auch festgeschrieben; mcp.h nachgezogen

skill_delete committet am Bibliotheks-Wurzel, weil das Verzeichnis der Fähigkeit
danach nicht mehr existiert. Dazu der behobene SIGCHLD-Fehler aus libmcp, der
alle git-Aufrufe im Dienst still scheitern ließ.

Nachgemessen im Dienst: "committed skilld: create probe-fuenf (b672b9b)".
This commit is contained in:
Hermes committed 2026-11-06 19:08:38 +00:00
1 parent c1c2ca0ef2
commit 34d4ae6a14
2 files changed
+32 -8

No files matched your search

+9 -1
View File
@@ -50,7 +50,9 @@ static void autocommit(const char *dir, const char *fmt, ...)
if (rc == 0)
fprintf(stderr, "skilld: committed %s (%s)\n", msg, hash ? hash : "?");
else if (rc < 0)
fprintf(stderr, "skilld: commit failed: %s\n", err);
fprintf(stderr, "skilld: commit failed in %s: %s\n", dir, err);
else
fprintf(stderr, "skilld: nothing to commit in %s\n", dir);
free(hash);
}
@@ -779,6 +781,12 @@ static void t_delete(mcp_conn *c, const mcp_json *args, void *user)
mcp_buf_printf(&msg, "could not delete '%s'", name);
mcp_reply_error(c, msg.p);
} else {
/* Am Bibliotheks-Wurzel festschreiben: das Verzeichnis der Fähigkeit
* gibt es nicht mehr, der Verlauf gehört aber zum Ganzen. */
char *lib = skilllib_path();
autocommit(lib, "skilld: delete %s", name);
free(lib);
mcp_buf_printf(&msg, "deleted '%s'", name);
mcp_reply_text(c, msg.p);
}
+23 -7
View File
@@ -175,6 +175,7 @@ char *mcp_handle(mcp_server *srv, const char *line);
#include <netinet/in.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <unistd.h>
#include <arpa/inet.h>
@@ -1090,8 +1091,13 @@ int mcp_serve_http(mcp_server *srv, const char *host, int port)
close(ls);
return 1;
}
/* fork per connection: without this every finished child stays a zombie */
signal(SIGCHLD, SIG_IGN);
/* Ein Prozess je Verbindung. Dabei NICHT SIGCHLD auf SIG_IGN setzen: das
* lässt den Kernel alle Kinder selbst einsammeln, und dann scheitert jedes
* pclose() im Programm mit ECHILD — popen sieht einen Fehler, obwohl das
* Kommando lief. Genau so scheiterten in skilld alle git-Aufrufe still.
* Stattdessen doppelt forken: das Zwischenkind beendet sich sofort, der
* Enkel gehört init und wird von dort eingesammelt. */
fprintf(stderr, "%s: http mcp on %s:%d (session %s)\n",
srv->name ? srv->name : "mcp", host ? host : "0.0.0.0", port, session);
for (;;) {
@@ -1102,14 +1108,24 @@ int mcp_serve_http(mcp_server *srv, const char *host, int port)
continue;
pid = fork();
if (pid == 0) {
close(ls);
mcp_http_serve_one(fd, srv, session);
_exit(0);
pid_t grand = fork();
if (grand == 0) {
close(ls);
mcp_http_serve_one(fd, srv, session);
_exit(0);
}
_exit(0); /* Zwischenkind: sofort weg, kein Zombie */
}
if (pid > 0)
if (pid > 0) {
int wstatus;
close(fd);
else
while (waitpid(pid, &wstatus, 0) < 0 && errno == EINTR)
;
} else {
mcp_http_serve_one(fd, srv, session);
}
}
}