Mail Archives: djgpp/1997/11/13/12:37:12
On Thu, 13 Nov 1997 12:15:17 +0200 (IST), Eli Zaretskii wrote:
> On Wed, 12 Nov 1997, Michael Mauch wrote:
>
> > > IMHO, a better way is to use the `select' library function. It is
> > > portable to Linux (and Unix in general) and calls `__dpmi_yield'
> > > internally while it waits. It also has a time-out option. Check it
> > > out in the library reference.
> >
> > Yes, thank you for pointing that out. The only draw-back I see is that
> > it doesn't work if stdin is redirected.
>
> Huh? It does work for me. Can you give an example where it doesn't?
> I used the test program created when you compile `select.c' in the
> libc sources with -DTEST.
Hmm, I checked that and it only kind of works (at least here, on Win95):
if stdin is not redirected, it waits until you press key and then prints
0: ready for input
0: ready for output
1: ready for input
1: ready for output
and the rest of it.
But if stdin is redirected, it immediately prints:
0: ready for input
0: ready for output
then it waits for the keystroke and prints the remainder.
Strange enough that I have to check if stdout is ready for input, but it
becomes worse if you redirect stdout as well:
in that case, stdout never becomes ready for input and select() waits
for 15 seconds before printing
1: NOT ready for input
1: ready for output
Does the select.exe work for you when you redirect both stdin and
stdout?
> No, I think calling `__dpmi_yield' *is* a good idea, since it is
> either ignored (when the environment doesn't support it) or makes
> the program multitasking-friendly in those environments which do. The
> bumpy mouse is probably caused by something else, not by
> `__dpmi_yield' itself.
Ok, then please, Robert, could you implement in the next release of
RHIDE?
> No, I think `kbhit' should work as advertised: only call the keyboard
> BIOS function. It's the responsibility of the programmer to yield the
> time-slice if that's what they want. Doing so is so easy that I don;t
> think it requires a bit in the crt0 flags (which is non-portable
> anyway).
Agreed.
Regards...
Michael
- Raw text -