linux: place alternate signal stack in stack area

The alternate stack must use the stack area as, e.g., Thread::myself()
depends on this property. Hybrid components do not depend on this
property and, therefore, use a static stack buffer.

Fixes #1935
This commit is contained in:
Christian Helmuth
2016-06-22 16:14:18 +02:00
parent d8c34237bf
commit d7ddc83fa9
6 changed files with 36 additions and 23 deletions

View File

@ -245,7 +245,7 @@ extern "C" void lx_restore_rt (void);
/**
* Simplified binding for sigaction system call
*/
inline int lx_sigaction(int signum, void (*handler)(int))
inline int lx_sigaction(int signum, void (*handler)(int), bool altstack)
{
struct kernel_sigaction act;
act.handler = handler;
@ -258,12 +258,16 @@ inline int lx_sigaction(int signum, void (*handler)(int))
* when leaving the signal handler and it should call the rt_sigreturn syscall.
*/
enum { SA_RESTORER = 0x04000000 };
act.flags = SA_RESTORER | SA_ONSTACK;
act.flags = SA_RESTORER;
act.restorer = lx_restore_rt;
#else
act.flags = SA_ONSTACK;
act.flags = 0;
act.restorer = 0;
#endif
/* use alternate signal stack if requested */
act.flags |= altstack ? SA_ONSTACK : 0;
lx_sigemptyset(&act.mask);
return lx_syscall(SYS_rt_sigaction, signum, &act, 0UL, _NSIG/8);