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]