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));