unix c help

david nugent david at csource.oz.au
Wed Jul 11 03:51:20 AEST 1990


In <1950 at novavax.UUCP> raab at novavax.UUCP (Moshe Raab) writes:

>i have been coding in c for a number of years. all of this
>time i have been programming using MSC, using the MS extensions.
>recently,  i installed  Mark Williams Coherent (unix like)
>operating system. i started writing  my own simple communications
>program but have hit some unexpected snags. for example, how does
>one monitor the keyboard and the com port at the same time.
>in MSC i use, kbhit(). i could theoretically write my own
>kbhit in assemlby using the bios call to interrup 0x16 but
>that would make it unportable. if any one has any suggestions,
>please let me know.


The whole approach of polling for input should be completely
scrapped. With Unix, you have _much_ better resource usage than
sitting in an idle loop wasting machine cycles.

Basically, to do this type of thing there are a number of
different angles.  The easiest is to use multiple processes,
each to wait on the activity you're monitoring - and effectively
'sleep' while nothing is happening.  The Unix 'cu' utility is a
good example; it uses fork() to generate a child process to
accept input from the port, and echo it to the screen via
stdout.  The parent process accepts keyboard input and passes
it out the port.



-- 
_______________________________________________________________________________
 Unique Computing Pty Ltd  Melbourne  Australia  -  Communications Specialists 
        david at csource.oz.au    3:632/348 at fidonet    28:4100/1 at signet           



More information about the Comp.lang.c mailing list