views:

44

answers:

1

I am migrating a LynxOS program to an ubuntu distribution and gcc 4.1.3

I am almost done but I have a problem, I am receiving SIGALRM signal which forces my program to exit. I dont know why I am receiving this signals if I am not calling to alarm(x).

I roundabouted this with a sigaction, but my program is not working properly mq_receive is failing every time this SIGALRM is received.

I wonder if it could be because of this code translation:

#include <events.h>
#include <timers.h>

evtset_t EvtMask;
struct timespec Time;

Time.tv_sec = 2;
Time.tv_nsec = 0;
evtsuspend (&EvtMask, &Time);

would now be

sleep(2);

This is the info about evtsuspend given by LynxOS:

evtsuspend (cant insert the image because of my lack of reputation)

Do you think they work the same? (without specifying an event mask) sleep() also waits for a SIGALRM to continue.

Thanks and regards

+3  A: 

1) Try running strace on your program to see if you can find out more info.

It'd be nice to have more details about your program... but maybe this will help.

Maybe mq_receive() is timing out. I think that SIGALRM is used to notify applications for timed-out system calls.

Or more likely, you're using something else that's causing SIGALRM in your code, ie: setitimer().

As for your question about using sleep(2) on linux. If you want the program to block during the sleep(2) call, then yes you should be OK with using it. If you don't want it to block, then start an interval timer setitimer() and use that. Note: setitimer() uses SIGALRM when the timer fires... see the manpage for details.

Steve Lazaridis