lkml.org 
[lkml]   [2001]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectA signal fairy tale
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
-
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/

\
 
 \ /
  Last update: 2005-03-22 12:55    [W:0.102 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site