Programación General > C/C++
No me funciona la E/S asíncrona en las tuberías con nombre
(1/1)
marcialre:
En el mismo directorio que el ejecutable hay una tubería con nombre llamada fifo (mkfifo fifo).
--- Código: C --- int main(){ int file; file = open("fifo", O_RDWR|O_ASYNC|O_NONBLOCK); if(file == -1) { puts("Error al abrir el archio "fifo"."); exit(EXIT_FAILURE); } signal(SIGIO, faction); pause(); close(file); exit(EXIT_SUCCESS);}
--- Código: C --- void faction(){ puts("SIGIO recibida.");} En principio se debería lanzar la señal SIGIO cuando otro proceso lee o escribe del archivo fifo. ¿En qué me equivoco?
SO: Linux 2.6.28, gcc.
Gracias.
Eternal Idol:
SIGIO (which is not specified in POSIX.1-2001) is ignored by default on several other Unices.
http://linux.die.net/man/7/signal
SIGIO is somewhat more complex than SIGPIPE. First, a call to ioctl() to request the enabling FIOASYNC is required to enable generation of this signal. Second, another call to ioctl() is required to request SIOCSPGRP, which sets the target process group. A target process group is either a process (specified by a positive process id) or a process group (specified by a negative process id).
http://docs.hp.com/en/32650-90372/ch02s14.html
Si lo anterior no funciona (los ioctl's) por lo que pude entender del libro "UNIX Programacion Avanzada" SIGIO es una señal que aparecio en BSD y puede que necesites usar la funcion que aparecio para las señales que incorporaron: sigvec.
Navegación
Ir a la versión completa