+void
+signal_dup_context(struct sigctx* dest_ctx)
+{
+ struct sigctx* old_ctx = ¤t_thread->sigctx;
+ memcpy(dest_ctx, old_ctx, sizeof(struct sigctx));
+}
+
+void
+signal_dup_registry(struct sigregistry* dest_reg)
+{
+ struct sigregistry* oldreg = __current->sigreg;
+ for (int i = 0; i < _SIG_NUM; i++) {
+ struct sigact* oldact = oldreg->signals[i];
+ if (!oldact) {
+ continue;
+ }
+
+ struct sigact* newact = valloc(sizeof(struct sigact));
+ memcpy(newact, oldact, sizeof(struct sigact));
+
+ dest_reg->signals[i] = newact;
+ }
+}
+
+void
+signal_reset_context(struct sigctx* sigctx) {
+ memset(sigctx, 0, sizeof(struct sigctx));
+}
+
+void
+signal_reset_registry(struct sigregistry* sigreg) {
+ for (int i = 0; i < _SIG_NUM; i++) {
+ struct sigact* act = sigreg->signals[i];
+ if (act) {
+ vfree(act);
+ sigreg->signals[i] = NULL;
+ }
+ }
+}
+
+void
+signal_free_registry(struct sigregistry* sigreg) {
+ signal_reset_registry(sigreg);
+ vfree(sigreg);
+}
+
+static bool
+signal_set_sigmask(struct thread* thread, int how, sigset_t* oldset, sigset_t* set)