linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Kegel <dank@kegel.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: A signal fairy tale
Date: Tue, 26 Jun 2001 05:54:37 -0700	[thread overview]
Message-ID: <3B38860D.8E07353D@kegel.com> (raw)

Once upon a time a hacker named Xman
wrote a library that used aio, and decided
to use sigtimedwait() to pick up completion
notifications.  It worked well, and his I/O
was blazing fast (since was using a copy
of Linux that was patched to have good aio).
But when he tried to integrate his library
into a large application someone else had
written, woe! that application's use of signals
conflicted with his library.  "Fsck!" said Xman.
At that moment a fairy appeared, and said
"Young man, watch your language, or I'm going to
have to turn you into a goon!  I'm the good fairy Eunice.  
Can I help you?"  Xman explained his problem to Eunice,
who smiled and said "All you need is right here,
just type 'man 2 sigopen'".  Xman did, and saw:

 
SIGOPEN(2)        Linux Programmer's Manual           SIGOPEN(2)
 
NAME
       sigopen - open a signal as a file descriptor
 
SYNOPSIS
       #include <signal.h>
 
       int sigopen(int signum);
 
DESCRIPTION
       The sigopen system call opens signal number signum as a file descriptor.
       That signal is no longer delivered normally or available for pickup
       with sigwait() et al.  Instead, it must be picked up by calling
       read() on the file descriptor returned by sigwait(); the buffer passed to
       read() must have a size which is a multiple of sizeof(siginfo_t).
       Multiple signals may be picked up with a single call to read().
       When that file descriptor is closed, the signal is available once more 
       for traditional use.
       A signal number cannot be opened more than once concurrently; sigopen() 
       thus provides a way to avoid signal usage clashes in large programs.

RETURN VALUE
       signal returns the new file descriptor, or -1 on error (in which case, errno
       is set appropriately).

ERRORS
       EWOULDBLOCK signal is already open

NOTES                                
       read() will block when reading from a file descriptor opened by sigopen()
       until a signal is available unless fcntl(fd, F_SETFL, O_NONBLOCK) is called
       to set it into nonblocking mode.

HISTORY
       sigopen() first appeared in the 2.5.2 Linux kernel.

Linux                      July, 2001                         1           

When he finished reading, he knew just how to solve his
problem, and he lived happily ever after.  

The End.

- Dan

             reply	other threads:[~2001-06-26 12:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-26 12:54 Dan Kegel [this message]
2001-06-27  3:56 ` A signal fairy tale Christopher Smith
2001-06-27  6:21 ` Balbir Singh
2001-06-27 18:11   ` Christopher Smith
2001-06-28  3:28     ` Balbir Singh
2001-06-27  9:18 ` Jamie Lokier
2001-06-27 18:16   ` Christopher Smith
2001-06-28 12:58 ` John Fremlin
2001-06-28 16:21   ` Jamie Lokier
2001-06-29  8:22 ` Christopher Smith
2001-06-29 11:47   ` John Fremlin
2001-06-28  2:49 Daniel R. Kegel
2001-06-29  8:18 ` Christopher Smith
2001-06-29  9:05   ` Dan Kegel
2001-06-28  2:57 Daniel R. Kegel
2001-06-29  8:19 ` Christopher Smith
2001-06-29  9:29   ` Dan Kegel
2001-06-29 18:46     ` Dan Kegel
2001-07-02 22:33       ` Christopher Smith
2001-06-28  3:04 Daniel R. Kegel
2001-06-28 14:46 ` Jamie Lokier
2001-06-28 20:11 Daniel R. Kegel
2001-06-29  8:31 ` Christopher Smith
     [not found] <fa.d69j5vv.ej8irj@ifi.uio.no>
     [not found] ` <fa.h2rpibv.87m5bp@ifi.uio.no>
2001-06-28 14:59   ` Dan Maas
2001-06-28 15:21     ` Alan Cox
2001-06-29  8:26   ` Christopher Smith
2001-06-29 11:56     ` Chris Wedgwood
2001-06-30 10:02     ` Jan Hudec

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=3B38860D.8E07353D@kegel.com \
    --to=dank@kegel.com \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).