Skip to content

Commit

Permalink
[ANDROID] Try to fix signal handling on android
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Dec 27, 2024
1 parent e2d7cc5 commit 4fd59da
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/include/signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ typedef struct x64_sigaction_s {
void (*sa_restorer)(void);
} x64_sigaction_t;

#ifdef ANDROID
typedef struct android_sigaction_s {
union {
sighandler_t _sa_handler;
void (*_sa_sigaction)(int, siginfo_t *, void *);
} _u;
sigset_t sa_mask;
uint32_t sa_flags;
void (*sa_restorer)(void);
} android_sigaction_t;
#endif

typedef struct x64_sigaction_restorer_s {
union {
sighandler_t _sa_handler;
Expand Down
12 changes: 12 additions & 0 deletions src/libtools/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,11 @@ EXPORT sighandler_t my_signal(x64emu_t* emu, int signum, sighandler_t handler)
EXPORT sighandler_t my___sysv_signal(x64emu_t* emu, int signum, sighandler_t handler) __attribute__((alias("my_signal")));
EXPORT sighandler_t my_sysv_signal(x64emu_t* emu, int signum, sighandler_t handler) __attribute__((alias("my_signal"))); // not completely exact

#ifdef ANDROID
int EXPORT my_sigaction(x64emu_t* emu, int signum, const android_sigaction_t *act, android_sigaction_t *oldact)
#else
int EXPORT my_sigaction(x64emu_t* emu, int signum, const x64_sigaction_t *act, x64_sigaction_t *oldact)
#endif
{
printf_log(LOG_DEBUG, "Sigaction(signum=%d, act=%p(f=%p, flags=0x%x), old=%p)\n", signum, act, act?act->_u._sa_handler:NULL, act?act->sa_flags:0, oldact);
if(signum<0 || signum>MAX_SIGNAL) {
Expand Down Expand Up @@ -2118,10 +2122,18 @@ int EXPORT my_sigaction(x64emu_t* emu, int signum, const x64_sigaction_t *act, x
}
return ret;
}
#ifdef ANDROID
int EXPORT my___sigaction(x64emu_t* emu, int signum, const android_sigaction_t *act, android_sigaction_t *oldact)
#else
int EXPORT my___sigaction(x64emu_t* emu, int signum, const x64_sigaction_t *act, x64_sigaction_t *oldact)
#endif
__attribute__((alias("my_sigaction")));

#ifdef ANDROID
int EXPORT my_syscall_rt_sigaction(x64emu_t* emu, int signum, const android_sigaction_restorer_t *act, android_sigaction_restorer_t *oldact, int sigsetsize)
#else
int EXPORT my_syscall_rt_sigaction(x64emu_t* emu, int signum, const x64_sigaction_restorer_t *act, x64_sigaction_restorer_t *oldact, int sigsetsize)
#endif
{
printf_log(LOG_DEBUG, "Syscall/Sigaction(signum=%d, act=%p, old=%p, size=%d)\n", signum, act, oldact, sigsetsize);
if(signum<0 || signum>MAX_SIGNAL) {
Expand Down

0 comments on commit 4fd59da

Please sign in to comment.