[comp.unix.sysv386] Portable versions of SCO Xenix/Unix nap

fields-doug@cs.yale.edu (Doug Fields) (03/27/91)

I am using the functions nap() and rdchk() in one of my programs.
I was wondering if anyone had any code to emulate these in a portable,
non-cpu intensive way. In case you don't know what these do:

  rdchk(f) - checks to see if a subsequent read would not block... I
             use it as rdchk(0) to see if the user has pressed a key
             yet. Returns 1 if there is input waiting.

  nap(t) - sleeps for t milliseconds. I use this to put a 1/5th of a
           second pause (nap(200)).

If there is no way to get nap() to work the program works just fine with
sleep(1) but it is a lot more slugish. As for rdchk, Apparently you can
use ioctl to set the VTIME and the other parameter to 0 and get a very
cpu-intensive form of rdchk.

Any help is appreiciated. Thanks.

Doug
-- 
Doug Fields -POB 1789 Yale Station, New Haven, CT 06520- (FAX) +1 203 661-2996
Internet: fields-doug@cs.yale.edu <-- Best to reach me. Voice: +1 203 436-0184
uucp: ...uunet!sir-alan!admiral!doug --------------------- Thank you Sir-Alan!
BBS: (T2500) +1 203 661-2873, (HST/V.32) -1279, (V.32) -0450, (v29/MNP6) -2967