ttl@aura.cs.wisc.edu (Tony Laundrie) (05/21/91)
I am doing some low-level I/O, and if the cables aren't all connected, then an inp() statement will hang forever. How do I set up a timeout in Turbo C or Microsoft C? I want to say something like: settimeout (2, timeout_error); /* in two seconds, call timeout_error() */ x = inp (); /* attempt input */ settimeout (0); /* cancel the timeout, 'cuz we succeeded */ Thanks. Please email--I will post summary. ttl@cs.wisc.edu
elvis@hammond.cs.unlv.edu (Frederick Haab) (05/22/91)
In article <1991May21.164600.10474@spool.cs.wisc.edu> ttl@aura.cs.wisc.edu (Tony Laundrie) writes: >I am doing some low-level I/O, and if the cables aren't all connected, >then an inp() statement will hang forever. How do I set up a timeout in >Turbo C or Microsoft C? > >I want to say something like: > > settimeout (2, timeout_error); /* in two seconds, > call timeout_error() */ > x = inp (); /* attempt input */ > settimeout (0); /* cancel the timeout, 'cuz > we succeeded */ > >Thanks. Please email--I will post summary. ttl@cs.wisc.edu I posted a small C program a few weeks ago that played music in the background. I'm sure you could use the same method to set a timed delay and then call a subroutine that would just terminate (do an exit(0) or something), but I don't know how you would just get your inp() function to stop. You could try putting a label after your inp() and then maybe *fix* the stack somehow so that it would seem the inp() function was never called. Just a thought... --==-- Frederick Haab --==--