cleanup
This commit is contained in:
20
2026/cscg/rev/gloomweaver/trace_hook.c
Normal file
20
2026/cscg/rev/gloomweaver/trace_hook.c
Normal file
@@ -0,0 +1,20 @@
|
||||
// trace_hook.c — intercept signal handler to log VM state
|
||||
#define _GNU_SOURCE
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
static FILE *trace;
|
||||
|
||||
int sigaction(int signum, const struct sigaction *act,
|
||||
struct sigaction *oldact) {
|
||||
// Log which signals are being registered
|
||||
if (!trace) trace = fopen("/tmp/vm_trace.txt", "w");
|
||||
fprintf(trace, "sigaction(%d)\n", signum);
|
||||
fflush(trace);
|
||||
|
||||
// Call real sigaction
|
||||
int (*real)(int, const struct sigaction*, struct sigaction*) =
|
||||
dlsym(RTLD_NEXT, "sigaction");
|
||||
return real(signum, act, oldact);
|
||||
}
|
||||
Reference in New Issue
Block a user