ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/06/27/01:43:53

Date: Tue, 27 Jun 1995 04:54:53 GMT
From: Kenny <kenny AT Freak DOT ORG>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: read()?

Hello,
  I am using DJGPP with maint5 and I was doing a program where this code is
put into effect:

for (;;) {
    while ((count = read(0, buffer, sizeof(buffer))) > 0) {
        got_some = 1;
        for (ptr = buffer, end = buffer + count; ptr < end; ptr++) {
            unsigned char       c = *ptr;

            if (isgraph(c)  ||  c == ' '  ||  c == '\t')
                stream_add_char(s, c);
            else if (c == '\n')
                server_receive_line(sh, reset_stream(s));
        }
    }

    if (got_some  ||  timeout == 0)
        goto done;

    sleep(1);
    timeout--;
}

I don't think the values of the variables are of significance right now.  I
changed read(0..etc to read(127..etc (which is invalid) to see what would happen
and it displayed the output I wanted but wouldn't get any input (obviously).
I changed it back to 0 and it just hangs there without displaying any output.
This code is part of Pavel's LambdaMOO server code.  I am trying to compile it
with DJGPP but this is the only major obstacle I have right now.  Is there
some bug with the read statement?  This works fine on my Linux box.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019