public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "who at connect dot carleton dot ca" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug manual/6745] New: si_code != SI_SIGIO when a signal is generated by queued SIGIO
Date: Mon, 14 Jul 2008 17:16:00 -0000	[thread overview]
Message-ID: <20080714171600.6745.who@connect.carleton.ca> (raw)

I'm trying to write a server application that will wait for incoming connections.

Whenever a client attempts to connect/read/write (basically when the socket
experiences activity) a signal is supposed to be triggered.

I used:
fcntl(socket, F_SETSIG, SIGIO);
fcntl(socket, F_SETFL, O_ASYNC | O_NONBLOCK);
fcntl(socket, F_SETOWN, getpid());

And:
struct sigaction action;
action.sa_sigaction = &MySigHandler;
action.sa_flags = SA_SIGINFO;
sigaction(SIGIO, &action, NULL);

According to the man pages, whenever there is activity in the socket "socket", a
signal will be raised. The signal would be handled by "MySigHandler", and since
the "SA_SIGINFO" flag was set, the signal would provide additional information
to the function. And here is when the unexpected behaviour occurs.

According to the manpages, the second parameter of the handler (siginfo_t *)
should contain additional information. Among the information, si_code is
supposed to have "SI_SIGIO" if the signal was generated by a queued SIGIO.

Instead of having SI_SIGIO (supposed to be -5) I get a value of 1. I also tried
"kill -s SIGIO <pid of server>" and got a value of 0 (SI_USER), which is the
expected value when the signal is raised by kill.

I'm currently using glib version 2.7-2 on Linux version 2.6.23.1-42.fc8.

To reproduce the problem simply setup a socket using fcntl (as above), make it
listen for incoming connections, and use sigaction (as above) to make a function
handle the signal. Inside the function, print out the contents of si_code. If
necessary, I can provide my own code.

-- 
           Summary: si_code != SI_SIGIO when a signal is generated by queued
                    SIGIO
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: manual
        AssignedTo: roland at gnu dot org
        ReportedBy: who at connect dot carleton dot ca
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=6745

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


             reply	other threads:[~2008-07-14 17:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-14 17:16 who at connect dot carleton dot ca [this message]
2008-07-14 17:29 ` [Bug manual/6745] " who at connect dot carleton dot ca
2008-07-14 17:29 ` who at connect dot carleton dot ca
2008-07-14 17:33 ` who at connect dot carleton dot ca
2008-07-15  7:00 ` halesh dot s at india dot com
2008-07-15 14:57 ` who at connect dot carleton dot ca

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=20080714171600.6745.who@connect.carleton.ca \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).