+void
+signal_reset_context(struct sigctx* sigctx) {
+ memset(sigctx, 0, sizeof(struct sigctx));
+}
+
+void
+signal_reset_register(struct sigregister* 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_registers(struct sigregister* sigreg) {
+ signal_reset_register(sigreg);
+ vfree(sigreg);
+}
+
+static bool
+signal_set_sigmask(struct thread* thread, int how, sigset_t* oldset, sigset_t* set)
+{
+ struct sigctx* sh = ¤t_thread->sigctx;
+ *oldset = sh->sig_mask;
+
+ if (how == _SIG_BLOCK) {
+ sigset_union(sh->sig_mask, *set);
+ } else if (how == _SIG_UNBLOCK) {
+ sigset_intersect(sh->sig_mask, ~(*set));
+ } else if (how == _SIG_SETMASK) {
+ sh->sig_mask = *set;