]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
displayd: Disable signal notification for incomming serial data
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 23 Apr 2010 14:53:58 +0000 (16:53 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 23 Apr 2010 14:56:08 +0000 (16:56 +0200)
Displayd was killed by SIGIO since it didn't handle the signal.

src/displayd/uoled.c
src/sercom/sercom.c

index 473de1d893be88a7869528f6383e125bf3066bfd..ec3a87f74a5b20b5986e36422722de2035dd5294 100644 (file)
@@ -31,7 +31,7 @@ struct sercom_data* uoled_init(char * tty, void(*sighandler)(int))
        sercom.databits = 8;
        sercom.stopbits = 1;
        sercom.mode = 0;
-       sercom.sighandler = sighandler;
+       sercom.sighandler = NULL;
        sercom_open(&sercom);
        return &sercom;
 }
index 55f93ee143a989319d4a61a908e290fe584321e0..034600e066e6afbd1dfa8423caa6198ed17a53fd 100644 (file)
@@ -192,18 +192,20 @@ void sercom_open(struct sercom_data *sercom)
                exit(-1);
        }
 
-       /* install the serial handler before making the device asynchronous */
-       sercom->saio.sa_handler = sercom->sighandler;
-       sercom->saio.sa_flags = 0;
-       sercom->saio.sa_restorer = NULL;
-       sigemptyset(&sercom->saio.sa_mask);   
-       sigaction(SIGIO, &sercom->saio, NULL);
+       if (sercom->sighandler) {
+               /* install the serial handler before making the device asynchronous */
+               sercom->saio.sa_handler = sercom->sighandler;
+               sercom->saio.sa_flags = 0;
+               sercom->saio.sa_restorer = NULL;
+               sigemptyset(&sercom->saio.sa_mask);   
+               sigaction(SIGIO, &sercom->saio, NULL);
        
-       /* allow the process to receive SIGIO */
-       fcntl(sercom->fd, F_SETOWN, getpid());
-       /* Make the file descriptor asynchronous (the manual page says only
-        * O_APPEND and O_NONBLOCK, will work with F_SETFL...) */
-       fcntl(sercom->fd, F_SETFL, O_NONBLOCK | FASYNC);
+               /* allow the process to receive SIGIO */
+               fcntl(sercom->fd, F_SETOWN, getpid());
+               /* Make the file descriptor asynchronous (the manual page says only
+                * O_APPEND and O_NONBLOCK, will work with F_SETFL...) */
+               fcntl(sercom->fd, F_SETFL, O_NONBLOCK | FASYNC);
+       }
        /* save current serial port settings */
        tcgetattr(sercom->fd, &sercom->oldtio);
        memset(&sercom->newtio, 0, sizeof(sercom->newtio));