lkml.org 
[lkml]   [1999]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectno signals from a named pipe

Hello!
Is my observed behavior correct? I find that R/W access to a named-pipe
can be detected with select() and poll(), but does not seem to
use a signal (not even SIGPIPE, SIGPOLL, or SIGIO)?



#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <poll.h>

#define FIFO "/tmp/foo"
void nothing(int sig)
{
fprintf(stdout, "Got signal %d\n", sig);
fflush(stdout);
(void)signal(sig, nothing);
}
int main()
{
char buf[0x100];

int fd;
int flags;
int len;
int i;
struct pollfd po;

for(i=1 ;i < 32 ; i++)
(void)signal(i, nothing);

(void)unlink(FIFO);
(void)mkfifo (FIFO, 0777);
fd = open(FIFO, O_RDWR);
flags = fcntl(fd, F_GETFL);
flags |= FASYNC;
if(fcntl(fd, F_SETFL, flags) < 0)
fprintf(stderr, "You can't do that (F_SETFL)!\n");

if(fcntl(fd, F_SETOWN, getpid()) < 0)
fprintf(stderr, "You can't do that (F_SETOWN)!\n");
for(;;)
{
po.fd = fd;
po.events = POLLIN;
poll(&po, 1, 0x00080000);
{
len = read(fd, buf, 0x100);
if(len > 0)
write(1, buf, len);
}
}
return 0;
}

Writes from another process are detected and displayed, i.e.,
`ls >/tmp/foo` works. However, no signal is generated.


Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.2.1 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
Wisdom : It's not a Y2K problem. It's a Y2Day problem.



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

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