开发者

Posix evtsuspend equivalent

I am migrating a L开发者_Python百科ynxOS 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


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.


I see this is an old topic, but here is an answer to the mq_receive() part of your question:

mq_receive() will unblock when a signal is received. When this happens, the return code will be set to -1 and errno will be set to EINTR. You can wrap code around your call to mq_receive() to check for this and recall it if necessary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜