Signals and urxvt version 9.18 then 9.20...

Patrick Serru patrik at serru.net
Thu Aug 7 00:39:30 CEST 2014


    Hi All,

    I wrote something like this, to check if a character is available:

 int GetCFrom (IOnum from, char *buff) {
 // Allways check the inputs.
 // "from"==kStdIn: Returns -1 if no character from stdin
 // "from"==kPipeIn: Returns -1 if no character from terminal keyboard
 // typical calls: (char c)
 // (c=GetCFrom(kStdIn))>=0 ? write(kPipeOut, &c, 1) :0;
 // (c=GetCFrom(kPipeIn))>=0 ? write(kStdOut, &c, 1) :0;
 fd_set  set;
 struct timeval tiOut={0};
 int rcvd;
   if (FdIsValid(from)) {
     FD_ZERO(&set); // Effacement de tout descripteur de l'ensemble "set"
     FD_SET(from, &set); // Ajouter le descripteur de cette entrée
     if (select(from+1, &set, NULL, NULL, &tiOut) < 0) // Sél. du jeu "set"
       exit(EXIT_SUCCESS); // Sortie normale (le pipe a été rompu)?
     if (FD_ISSET(from, &set)) { // Si l'entrée du pipe ne bloquera pas
       if ((rcvd=read(from, buff, 1))!=1) // Lire ce qui y est disponible
         exit(EXIT_SUCCESS); // Sortie normale (le pipe a été rompu)?
       return(*buff);
     }
   }
   return(-1);
 }

    Everything was OK until I want to use signals. Whatever the type of signal 
(I do not remember trying the "real-time signals," but SIGUSR1 and 2, yes). 
The last I tried was using setitimer (ITIMER_REAL: SIGALRM, in my case). 
Always the same symptoms: program execution is abandoned on the signal 
FOLLOWING the pressing of a key. Unable to trap the error because the program 
was leaving "normally". I saw the difference when I changed both EXIT_SUCCESS 
above by EXIT_FAILURE.

    I installed version 9.20. It seems strange to me that with this version, 
it leaves after the first signal FOLLOWING the return ('\r') now, instead of 
any key. It could be more than the '\r' key pressed, but until now, I dont 
know.

    I just tryed xterm : the result is identical!

    Please, What can I do to be able to use setitimer in my software ?

    Sincerly,
Patrick Serru




More information about the rxvt-unicode mailing list