Thank you for your comment.
I have two cases in that select() should returns,
. when any of the descriptors are ready
. when a specific signal(ie, SIGUSR1) is pending
What I want to do is like this:
unblock SIGUSR1
select();
block SIGUSR1
This code seems good, but has a problem.
If a SIGUSR1 signal arrives between unblock and select(), the signal is lost.
so, select() can sleep forerver.
pselect() can correct the above problem
because we can handle the signal mask atomically with pselect().
pselect() in LINUX doesn't support signal-mask.
why is that?
-----Original Message-----
From: Glynn Clements [SMTP:[EMAIL PROTECTED]]
Sent: Thursday, November 25, 1999 9:48 PM
To: SungHawk Kim
Cc: 'Linux-Net'
Subject: Re: pselect() system call
SungHawk Kim wrote:
> I have a problem with my socket program.
>
> I'd like to use pselect() system call because I want to implement
> signal-safe code. the original prototype of pselect() is like this:
>
> int pselect(int maxfd, fd_set *readset, fd_set *writeset, fd_set *exceptset,
> const struct timespec *timeout, const sigset_t *sigmask);
>
> But, linux, actually glibc doesn't support the signal-mask argument of
> pselect().
What is the significance of the sigmask argument? Does it block the
specified signals, or just cause select() to ignore them?
> Is there any way to implement signal-safe code using not pselect() but
> select()?
You can block a given set of signals with sigprocmask(), e.g.:
sigset_t oldset, newset;
sigemptyset(&newset);
sigaddset(&newset, signum);
...
sigprocmask(SIG_BLOCK, &newset, &oldset);
select(...);
sigprocmask(SIG_SETMASK, &oldset, NULL);
You can write a wrapper around select() which ignores *all* signals by
calling select() repeatedly (updating the timeout on each call) until
it returns a nonzero descriptor count.
--
Glynn Clements <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]