POSIX requires that execve resets all signal handlers to SIG_DFL
(except SIG_IGN) and clears pending signals. Without this, the
kernel could attempt to deliver a signal to a handler address in
the destroyed old address space, causing a crash.
Also removed debug trace code (ldso trace, write trace, exit trace,
PTE dumps, GOT dumps) that was added during debugging and was
interfering with test output.
#include "process.h"
#include "spinlock.h"
#include "uaccess.h"
+
#include "console.h"
#include "utils.h"
}
}
+ /* POSIX: execve resets signal handlers to default (except SIG_IGN)
+ * and clears pending signals. Handlers pointing into the old
+ * address space would crash after the old AS is destroyed. */
+ current_process->sig_pending_mask = 0;
+ for (int si = 1; si < PROCESS_MAX_SIG; si++) {
+ uintptr_t h = (uintptr_t)current_process->sigactions[si].sa_handler;
+ if (h != (uintptr_t)1) /* SIG_IGN stays ignored */
+ current_process->sigactions[si].sa_handler = 0; /* SIG_DFL */
+ }
+
if (old_as && old_as != new_as) {
vmm_as_destroy(old_as);
}