Jump to content

sigaction() support for divide-by-zero exception

Recommended Posts

Hello KOS Team!

I've read here https://support.kaspersky.com/help/KCE/1.1/en-US/posix_uns_ifaces.htm that signals are not fully supported within KOS. But it is not clear on what extent. I can't find within the list the sigaction(). There is a simple app compiled with KOS SDK:

#include <stdio.h>
#include <stdlib.h>
#include <strict/posix/signal.h>
void signal_me (int signum, siginfo_t *si, void *context);
void signal_me (int signum, siginfo_t *si, void *context)
    fprintf(stderr, "divide by zero\n");
int main(int argc, const char *argv[])
    struct sigaction sigact;
    sigact.sa_sigaction = signal_me;
    sigact.sa_flags = SA_SIGINFO | SA_RESTART;
    if (sigaction (SIGFPE, &sigact, NULL) != 0) {
        fprintf(stderr,"sigaction returned error %d\n", 123);
    int num = 4 / 0;
    // no dependency from vfs_entity when using stderr
    fprintf(stderr,"Hello world: %d!\n", num);
    return EXIT_SUCCESS;

I try to setup divide-by-zero handler. Is it possible?

Output from KOS:

Unhandled Debug Exception
ESR = 0xf20003e8
EC = 0x3c
Exception class: BRK instruction execution in AArch64 state
    EIID : hello.Hello
    Name : hello.Hello
    Path : Hello
    TID  : 24
    pc   : 0x4100a0
    CPU  : 00

Trap Frame:
    x0 : 0x0000000000000000, x1 : 0x0000000000411d00, x2 : 0x000000000049fcc0, x3 : 0x000000000049fe00
    x4 : 0x0000000000496260, x5 : 0x0000000000000042, x6 : 0x0000000000123f40, x7 : 0x0000000000411594
    x8 : 0x0000000000496b08, x9 : 0x000000000049cad8, x10: 0x0000000000000000, x11: 0x0000000000000201
    x12: 0x0101010101010101, x13: 0x0000000000000030, x14: 0x000000000000003f, x15: 0x0000000000123e78
    x16: 0x000000000046beb0, x17: 0x000000008d757ac4, x18: 0x00000000004100a0, x19: 0x0000000000496260
    x20: 0x0000000000496260, x21: 0x00000000004a0000, x22: 0x0000000000480460, x23: 0x0000000000496a30
    x24: 0x0000000000000000, x25: 0x0000000000000000, x26: 0x0000000000000000, x27: 0x0000000000000000
    x28: 0x0000000000000000, x29: 0x0000000000123f00
    sp: 0xffffc400096e4000, lr: 0x000000000041009c, pc: 0x00000000004100a0
    usr_sp: 0x0000000000123f00, pstate: 0x0000000080000000, mode: User

Stack Data From 0xffffc400096e3ff0
+00 00000000004100a0 0000000000000000
Call Trace (User Mode):
    [<00000000004100a0>] (main+0x48) from [<00000000004115a8>] (__eprol+0x70)
    [<00000000004115a8>] (__eprol+0x70)

Terminating task.
Terminating thread.
[INIT ] System worker finished
[INIT ] System halted...


Do I understand right that signals can't be trapped on KOS at all and that app will exit on exception? Is there any plans of signal trapping support within KOS?



Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.