|
Home > Archive > Unix Programming > July 2005 > pause() and raise()
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
pause() and raise()
|
|
| Josh Birnbaum 2005-07-30, 2:49 am |
| Hi Folks,
I have a daemon code that, after initialization and the installation of
signal handlers (via sigset(2)), enters a for(;;) loop and calls
pause(2).
I'm sending SIGUSR1 and SIGUSR2, via kill() (eg. % kill -16
<daemon_pid> ),
to the daemon to invoke code triggered by the reception of these 2
signals.
What I would also like to do is to use raise(3C) to have the daemon send
SIGUSR1 and SIGUSR2 to itself at a user defined interval, thus invoking
the above code.
Code invocation via pause(2) or raise(3C) has to be separate (ie. I
cannot
call raise(3C) from within the for(;;) loop containing the pause(2)
call.
Nor can I call raise(3C) from within any code executed as a result of a
call from out of pause(2).
The thing is that in the current scenario, the raise(3C) calls will
never
be executed.
I'm working on this locally but I also wanted to put this to the group
to see if anyone had any feedback on the above.
Thanks,
Josh.
| |
| Maxim Yegorushkin 2005-07-30, 2:49 am |
| Josh Birnbaum wrote:
> Hi Folks,
>
> I have a daemon code that, after initialization and the installation of
> signal handlers (via sigset(2)), enters a for(;;) loop and calls
> pause(2).
>
> I'm sending SIGUSR1 and SIGUSR2, via kill() (eg. % kill -16
> <daemon_pid> ),
> to the daemon to invoke code triggered by the reception of these 2
> signals.
> What I would also like to do is to use raise(3C) to have the daemon send
> SIGUSR1 and SIGUSR2 to itself at a user defined interval, thus invoking
> the above code.
>
> Code invocation via pause(2) or raise(3C) has to be separate (ie. I
> cannot
> call raise(3C) from within the for(;;) loop containing the pause(2)
> call.
> Nor can I call raise(3C) from within any code executed as a result of a
> call from out of pause(2).
> The thing is that in the current scenario, the raise(3C) calls will
> never
> be executed.
Why can't you call raise() and what do you use pause() for? This all
sounds odd.
Can't you just process signals synchronously using sigtimedwait?
| |
|
| Maxim Yegorushkin wrote:
> Josh Birnbaum wrote:
>
>
>
> Why can't you call raise() and what do you use pause() for? This all
> sounds odd.
>
> Can't you just process signals synchronously using sigtimedwait?
>
Silly, indeed.
How about setting an alarm ? It would make the pause() return,
or you could even make the alarm signalhandler send signals to self.
Even more silly, I agree. Replacing the pause() by a sleep() like
systemcall would basically do what you want a lot easyer.
HTH,
AvK
|
|
|
|
|