Skip to content

Commit 48bd3d8

Browse files
committed
Fix sigaction() return handler address on XNU/BSD
1 parent bd56a9c commit 48bd3d8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

libc/calls/sigaction.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,24 @@ static int __sigaction(int sig, const struct sigaction *act,
251251
}
252252
if (rc != -1) {
253253
sigaction_native2cosmo((union metasigaction *)oldact);
254+
if (oldact && //
255+
oldact->sa_handler != SIG_DFL && //
256+
oldact->sa_handler != SIG_IGN && //
257+
(IsFreebsd() || IsOpenbsd() || IsNetbsd() || IsXnu())) {
258+
oldact->sa_handler =
259+
(sighandler_t)((uintptr_t)__executable_start + __sighandrvas[sig]);
260+
}
254261
}
255262
} else {
256263
if (oldact) {
257264
bzero(oldact, sizeof(*oldact));
258265
oldrva = __sighandrvas[sig];
266+
oldact->sa_mask = __sighandmask[sig];
259267
oldact->sa_flags = __sighandflags[sig];
260268
oldact->sa_sigaction =
261269
(sigaction_f)(oldrva < kSigactionMinRva
262270
? oldrva
263-
: (intptr_t)&__executable_start + oldrva);
271+
: (uintptr_t)&__executable_start + oldrva);
264272
}
265273
rc = 0;
266274
}

0 commit comments

Comments
 (0)