|
|
| Next: SMP Linux : limiting TX on few cpu |
| Author |
Message |
MikeB External

Since: Aug 07, 2007 Posts: 2
|
Posted: Tue Aug 07, 2007 6:52 pm Post subject: Registering for SIGPOLL signals from a named pipe Archived from groups: comp>os>linux>development>system (more info?) |
|
|
Hi,
I'd firstly like to apologise in advance in case this isn't the right group
for this message. If it's not the correct group, I'd appreciate some
indication of a better place to post.
A colleague has inherited rather a large lump of Solaris code which he is
porting to Linux. One area that is causing some difficulty is where the
original code uses ioctl in order to register for SIGPOLL signals when
events occur on a named pipe.
The code he has fails when calling ioctl. Having read the docs, he's sure
that this should work so he has simplified the code as much as possible and
it still fails.
I was wondering if any of our Linux developers can clarify whether or not
the following snippet should work:
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stropts.h>
#include <unistd.h>
int main ()
{
int fd;
/* /tmp/testpipe has already been created using mkfifo */
if ((fd = open("/tmp/testpipe", O_NONBLOCK | O_RDONLY)) == -1)
{
perror("open");
exit(1);
}
if( ioctl( fd, I_SETSIG, S_RDNORM) < 0)
{
/* ioctl call fails, reporting "ioctl: Invalid argument" */
perror( "ioctl");
exit(1);
}
close (fd);
return 0;
}
Rgds and TIA,
MikeB |
|
| Back to top |
|
 |
Paul Vojta External

Since: Apr 04, 2004 Posts: 4
|
Posted: Tue Aug 07, 2007 7:21 pm Post subject: Re: Registering for SIGPOLL signals from a named pipe [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
In article <f9abhd$qaf$1$8300dec7@news.demon.co.uk>,
MikeB <objectivedynamics RemoveThis @hotmail.com> wrote:
>
>Hi,
>
>I'd firstly like to apologise in advance in case this isn't the right group
>for this message. If it's not the correct group, I'd appreciate some
>indication of a better place to post.
>
>A colleague has inherited rather a large lump of Solaris code which he is
>porting to Linux. One area that is causing some difficulty is where the
>original code uses ioctl in order to register for SIGPOLL signals when
>events occur on a named pipe.
> if( ioctl( fd, I_SETSIG, S_RDNORM) < 0)
This is specific to STREAMS. There is a STREAMS package for Linux, but
it's an add-on, and I don't know anything about it.
Instead, try:
fcntl(fd, F_SETOWN, getpid())
followed by
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FASYNC)
This is for a socket; I don't know the difference with named pipes.
Hope this helps.
--Paul Vojta, vojta RemoveThis @math.berkeley.edu |
|
| Back to top |
|
 |
MikeB External

Since: Aug 07, 2007 Posts: 2
|
Posted: Tue Aug 07, 2007 9:13 pm Post subject: Re: Registering for SIGPOLL signals from a named pipe [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
"Paul Vojta" <vojta.DeleteThis@math.berkeley.edu> wrote in message
news:f9ago9$1hcn$1@agate.berkeley.edu...
> This is specific to STREAMS. There is a STREAMS package for Linux, but
> it's an add-on, and I don't know anything about it.
Paul,
many thanks for your reply. At the very least it's revealed that there's a
STREAMS package for Linux. I'll forward this information.
Rgds,
MikeB |
|
| Back to top |
|
 |
Rainer Weikusat External

Since: Apr 02, 2007 Posts: 105
|
Posted: Wed Aug 08, 2007 2:12 am Post subject: Re: Registering for SIGPOLL signals from a named pipe [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
"MikeB" <objectivedynamics DeleteThis @hotmail.com> writes:
> "Paul Vojta" <vojta DeleteThis @math.berkeley.edu> wrote in message
> news:f9ago9$1hcn$1@agate.berkeley.edu...
>> This is specific to STREAMS. There is a STREAMS package for Linux, but
>> it's an add-on, and I don't know anything about it.
>
> many thanks for your reply. At the very least it's revealed that there's a
> STREAMS package for Linux. I'll forward this information.
Unless you are specifically using STREAMS functionality (like STREAMS
modules), you are probably better of using the native ways to
accomplish things. For Linux, this would be O_ASYNC (FASYNC is a
BSD-compatibility macro) and SIGIO (SIGPOLL is a SysV compatibility
macro).
Additionally, it is possible to use F_SETSIG (fcntl) to request that a
specific other signal 'happens' if I/O on a particular file descriptor
becomes possible. |
|
| Back to top |
|
 |
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|