public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk" <mtk-lkml@gmx.net>
To: dwmw2@infradead.org
Cc: drepper@redhat.com, jakub@redhat.com, torvalds@osdl.org,
	linux-kernel@vger.kernel.org, akpm@osdl.org,
	michael.kerrisk@gmx.net
Subject: Re: Add pselect, ppoll system calls.
Date: Fri, 5 Aug 2005 14:49:28 +0200 (MEST)	[thread overview]
Message-ID: <25911.1123246168@www3.gmx.net> (raw)
In-Reply-To: 11156.1123243084@www3.gmx.net

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 3864 bytes --]

Hi David,

Not sure if your message below was meant as a reply-all or not,
but I've brought it back onto the list.

There are some problems with your test program -- 
it's not actually using pselect() in proper way, which is:

    /* Block signals that will be later unblocked by pselect() */

    sigemptyset(&block);
    sigaddset(&block, SIGINT);
    sigprocmask(SIG_BLOCK, &block, NULL);

    sigemptyset(&set);
    status = my_pselect(1, &s, NULL, NULL, &timeout, &set);

If I change your program to do something like the above, I also
do not see a message from the handler -- i.e., it is not being
called, and I'm pretty sure it should be.

Below, is my modified version of your program -- it uses SIGINT.

Cheers,

Michael

#define _GNU_SOURCE
#include <syscall.h>
#include <unistd.h>
#include <signal.h>
#include <sys/select.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>

#define __NR_pselect6 289

static int my_pselect(int   n,
       fd_set   *readfds,  fd_set  *writefds,  fd_set
       *exceptfds, const struct timespec *timeout, sigset_t *sigmask)
{
        struct {
                sigset_t *set;
                size_t size;
        } __attribute__((packed)) arg6;

        arg6.size = 8;
        arg6.set = sigmask;
        return syscall(__NR_pselect6, n, readfds, writefds,
                exceptfds, timeout, &arg6);
}

static void usr1_handler(int signo)
{
        write(1, "handler called\n", 20);
}


int main(void)
{
        fd_set s;
        int status;
        sigset_t set, block;
        struct timespec timeout;

        timeout.tv_sec = 30;
        timeout.tv_nsec = 0;

        FD_ZERO(&s);
        FD_SET(0, &s);

        signal(SIGINT, usr1_handler);

        sigemptyset(&block);
        sigaddset(&block, SIGINT);
        sigprocmask(SIG_BLOCK, &block, NULL);

        sigemptyset(&set);
        status = my_pselect(1, &s, NULL, NULL, &timeout, &set);
        printf("status=%d\n", status);
        if (status == -1) perror("pselect");
}

--- Weitergeleitete Nachricht ---
Von: David Woodhouse <dwmw2@infradead.org>
An: Michael Kerrisk <mtk-lkml@gmx.net>
Betreff: Re: Add pselect, ppoll system calls.
Datum: Fri, 05 Aug 2005 13:03:14 +0100

This is the test program I used. I send it SIGUSR1 manually.

#define __USE_MISC
#include <unistd.h>
#include <signal.h>
#include <sys/select.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>

#define __NR_pselect6 273

int my_pselect(int   n,   fd_set   *readfds,  fd_set  *writefds,  fd_set
       *exceptfds, const struct timespec *timeout, const sigset_t *sigmask)
{
        struct {
                sigset_t *set;
                size_t size;
        } __attribute__((packed)) arg6;

        arg6.size = 8;
        arg6.set = sigmask;
        return syscall(__NR_pselect6, n, readfds, writefds, exceptfds,
timeout, &arg6);
}

void usr1_handler(int signo)
{
        write(1, "usr1_handler called\n", 20);
}
int main(void)
{
        fd_set s;
        int p;
        char buf[80];
        sigset_t set;
        fcntl(0, F_SETFL, O_NONBLOCK | fcntl(0, F_GETFL));

        FD_ZERO(&s);
        FD_SET(0, &s);

        sigfillset(&set);

        signal(SIGUSR1, usr1_handler);

        printf("I am %d\n", getpid());

        while (1) {
                printf("Block usr1\n");
                fflush(stdout);
                sigaddset(&set, SIGUSR1);
                my_pselect(1, &s, NULL, NULL, NULL, &set);
                read(0, buf, 80);
                printf("Allow usr1\n");
                fflush(stdout);
                sigdelset(&set, SIGUSR1);
                my_pselect(1, &s, NULL, NULL, NULL, &set);
                read(0, buf, 80);
        }

}


-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++

  reply	other threads:[~2005-08-05 12:49 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-10 22:58 Add pselect, ppoll system calls David Woodhouse
2005-06-12 22:48 ` Alan Cox
2005-06-13  0:26   ` Linus Torvalds
2005-06-13  1:16     ` jnf
2005-06-13  3:26       ` Linus Torvalds
2005-06-13  6:22         ` Ulrich Drepper
2005-06-13  9:16           ` bert hubert
2005-06-13  9:41             ` David Woodhouse
2005-06-13 11:05               ` Christoph Hellwig
2005-06-13 11:14                 ` Jakub Jelinek
2005-06-13 11:24                   ` David Woodhouse
2005-06-13 15:38                     ` Ulrich Drepper
2005-06-13 16:02                       ` David Woodhouse
2005-06-13 16:10                         ` Ulrich Drepper
2005-06-13 16:29                           ` David Woodhouse
2005-06-13 16:31                             ` Ulrich Drepper
2005-06-13 21:58                               ` David Woodhouse
2005-06-13 22:01                                 ` Ulrich Drepper
2005-06-13 16:36                             ` Jakub Jelinek
2005-06-15 11:36                       ` David Woodhouse
2005-08-05 10:42                         ` pselect() modifying timeout Michael Kerrisk
2005-08-05 14:50                           ` Ulrich Drepper
2005-08-05 20:08                             ` Michael Kerrisk
2005-08-08 11:10                           ` Alan Cox
2005-08-05 11:58                         ` Add pselect, ppoll system calls Michael Kerrisk
2005-08-05 12:49                           ` Michael Kerrisk [this message]
2005-08-25  0:04                             ` David Woodhouse
2005-08-25  0:34                               ` Ulrich Drepper
2005-08-26  6:46                               ` Michael Kerrisk
2005-06-13 15:35                 ` Ulrich Drepper
2005-06-13  7:23         ` Benjamin Herrenschmidt
2005-06-13  7:29           ` David Woodhouse
2005-06-13 22:56             ` Benjamin Herrenschmidt
2005-06-13 11:15     ` Alan Cox
2005-06-13 11:27       ` David Woodhouse
2005-06-13 15:40       ` Ulrich Drepper
  -- strict thread matches above, loose matches on Subject: below --
2005-06-13 19:38 Mattias Engdegård
2005-06-13 19:57 ` Chris Friesen
2005-06-13 20:08   ` Mattias Engdegård
2005-06-13 20:23     ` Valdis.Kletnieks
2005-06-14 14:07       ` Mattias Engdegård
2005-06-14 14:16         ` Bernd Petrovitsch
2005-06-14 14:42           ` Mattias Engdegård
2005-06-14 14:54             ` Bernd Petrovitsch
2005-06-14 15:27         ` Valdis.Kletnieks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25911.1123246168@www3.gmx.net \
    --to=mtk-lkml@gmx.net \
    --cc=akpm@osdl.org \
    --cc=drepper@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=jakub@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.kerrisk@gmx.net \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox