X-Git-Url: http://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fdata%2Fvirtmodem.c;fp=common%2Fdata%2Fvirtmodem.c;h=169b11760953e521afc617d87fdf862fa419cfc4;hp=f6f1f3e317681b71b1012e2f1afe3d38f6faed2f;hb=35acc80f23f9f81f3145a686a9c7df4b622b25fe;hpb=a1a9e7f1909a21b98a6b21a660d5bc9bd9f11f81 diff --git a/common/data/virtmodem.c b/common/data/virtmodem.c index f6f1f3e..169b117 100644 --- a/common/data/virtmodem.c +++ b/common/data/virtmodem.c @@ -136,10 +136,12 @@ bool VM_ThreadLoop(void) FD_ZERO(&readfds); FD_SET(PtyRDFD,&readfds); + FD_SET(device_portfd,&readfds); timeout.tv_sec=2; timeout.tv_usec=0;/*500*1000;*/ - res = select(PtyRDFD+1,&readfds,NULL/*writefds*/,NULL/*exceptfds*/,&timeout); + res = select((device_portfd > PtyRDFD ? device_portfd : PtyRDFD)+1, + &readfds,NULL/*writefds*/,NULL/*exceptfds*/,&timeout); switch (res) { case 0: /* Timeout */ @@ -155,9 +157,12 @@ bool VM_ThreadLoop(void) return (false); default: - if (FD_ISSET(PtyRDFD,&readfds)) { + if (FD_ISSET(PtyRDFD,&readfds)) VM_CharHandler(); - } else usleep(500); /* Probably the file has been closed */ + if (FD_ISSET(device_portfd,&readfds)) + SigHandler(0); + if (!FD_ISSET(PtyRDFD,&readfds) && !FD_ISSET(device_portfd,&readfds)) + usleep(500); /* Probably the file has been closed */ break; } }