Re: Synchronous signal delivery..

From: Werner Almesberger (wa@almesberger.net)
Date: Sat Feb 15 2003 - 00:14:02 EST


I wrote:
> ssize_t overwrite(int fd,
> const void *data_if_empty,size_t size_if_empty,
> const void *data_if_full,size_t size_if_full,
> int *was_empty);

Bah, rubbish. Make this

    ssize_t overwrite(int fd,const void *data,size_t size);

If the pipe/queue is empty, don't write, and return 0. Now, this
could probably be implemented with a flag to send(2) (then this
wouldn't work for pipes, but you could use socketpair(2) for a
similar effect). Example:

void add_signal(int signum)
{
        static int signal_set = 0;
        int new_signal = 1 << signum;
        int sent;

        signal_set |= new_signal;
        sent = send(fd,&signal_set,sizeof(int),MSG_OVERWRITE);
        if (!sent) {
                send(fd,&new_signal,sizeof(int),0);
                signal_set = new_signal;
        }
}

- Werner

-- 
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Feb 15 2003 - 22:01:00 EST