On Wednesday 09 June 2004 23:48, Shachar Shemesh wrote:
> RTFM pselect, and more specifically, select_tut, for an answer to that 
> one.

I am fully aware for pselect importance in the general case, but I was 
refering to your specific example in which it was used only to wait for
the event to happen (or was I wrong and I/O was also involved?).

In that case, simply waiting for either signal to happen (it's a one-shot
signal) without blocking the other should be ok.

[BTW, I first leant from your remark about the select_tut manpage...nice].

> I'm not sure I see how sigprocmask enters into the picture. 

My flop, I was talking about sigsuspend (to wait for either SIGCHLD
or SIGALRM) and wrote sigprocmask :-(

> Still, I think this is a jackpot. Suggested pseudo code:
> sigprocmask disabling SIGCHILD and SIGALRM
> ask for ualarm for wakeup
> fork (child starts ping, with or without cancelling ualarm first)
> sigsupend on the above two signals
> check which one, send INT to ping if alrm
> waitpid
> return mask to usual, cancel alarm, etc.

Good. (s/sigprocmask/sigsuspend/ in my original paragraph and you'll
see we meant the same thing).

After sending the old reply I found another problem: man ualarm shows
nothing -- does my memory misslead me? I thought it was (almost-)stanard
[i.e: very common in Unices including Linux]

About disturbing other alarm/ualarms, you may want to look at Stevens
[advanced programming in the Unix environment, circa 1995] which has
a very nice chapter about implementing sleep(3) using alarm(2) with all
the common pittfalls (saving timers while setting them, avoiding critical
races in that stage, etc.)

-- 
Oron Peled                             Voice/Fax: +972-4-8228492
[EMAIL PROTECTED]                  http://www.actcom.co.il/~oron

Linux lasts longer!
                        -- "Kim J. Brand" <[EMAIL PROTECTED]>


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to