RE: [Refdb-users] RE: refdbc and php4
Status: Beta
                
                Brought to you by:
                
                    mhoenicka
                    
                
            | 
     
      
      
      From: Markus H. <mar...@mh...> - 2003-02-15 21:16:22
      
     
   | 
Alan Anderson writes: > I'm OK with this, but I wonder if there isn't a more elegant solution. How do common programs > handle it? For example, grep, cat, head, tail, etc. all seem to work in all situations. Can you > model what they do? They use calls like ioctl(fd, FIONREAD, &numbytes) to find out about the number of bytes waiting to be read. This is unfortunately not portable. Last time I tried Cygwin didn't implement this particular ioctl call due to inherent limitations in the Win32 API so this wouldn't work on a fairly popular platform. Unfortunately ioctl doesn't return an error on Cygwin in this case but crashes right away, so there's no way to find out at runtime whether this is going to work. I could test at compile time whether FIONREAD is defined, though (I hope it isn't defined in Cygwin when the call doesn't work anyway). In this case, you could rely on the automatic check on all platforms that support this ioctl call, but '-f stdin' would be mandatory on Cygwin and maybe some other obscure platforms. > > FYI, I don't think this is critical to what I'm doing, so unless someone else is interested in this > functionality, it may not be worth the effort. I'd like to fix this problem while I'm at it. It won't take long until someone else needs this feature. regards, Markus -- Markus Hoenicka mar...@ca... (Spam-protected email: replace the quadrupeds with "mhoenicka") http://www.mhoenicka.de  |