• Domingo 19 de Mayo de 2024, 16:11

Autor Tema:  No me funciona la E/S asíncrona en las tuberías con nombre  (Leído 1025 veces)

marcialre

  • Nuevo Miembro
  • *
  • Mensajes: 11
    • Ver Perfil
No me funciona la E/S asíncrona en las tuberías con nombre
« en: Sábado 24 de Octubre de 2009, 17:53 »
0
En el mismo directorio que el ejecutable hay una tubería con nombre llamada fifo (mkfifo fifo).
Código: C
  1.  
  2. int main()
  3. {
  4.    int file;
  5.    file = open("fifo", O_RDWR|O_ASYNC|O_NONBLOCK);
  6.    if(file == -1)
  7.    {
  8.       puts("Error al abrir el archio "fifo".");
  9.       exit(EXIT_FAILURE);
  10.    }
  11.    signal(SIGIO, faction);
  12.    pause();
  13.    close(file);
  14.    exit(EXIT_SUCCESS);
  15. }
  16.  
  17.  
Código: C
  1.  
  2. void faction()
  3. {
  4.    puts("SIGIO recibida.");
  5. }
  6.  
  7.  
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

  • Moderador
  • ******
  • Mensajes: 4696
  • Nacionalidad: ar
    • Ver Perfil
Re: No me funciona la E/S asíncrona en las tuberías con nombre
« Respuesta #1 en: Sábado 24 de Octubre de 2009, 19:13 »
0
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.

Nacional y Popular En mi país la bandera de Eva es inmortal.


Queremos una Argentina socialmente justa, económicamente libre y  políticamente soberana.
¡Perón cumple, Evita dignifica!


La mano invisible del mercado me robo la billetera.