[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mingw-users] Grep 2.5 for MinGW [Was: Problem with Grep]

From: Earnie Boyd
Subject: Re: [Mingw-users] Grep 2.5 for MinGW [Was: Problem with Grep]
Date: Wed, 30 Oct 2002 07:47:32 -0500
User-agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1) Gecko/20020826

CC: make-w32 because this has direct effect on implementation.

Wu Yongwei wrote:
Check the following simple program:

#include <io.h>
#include <stdio.h>
#include <errno.h>

int main()
    char buf[30705];
    int n;
    //setvbuf(stdin, NULL, _IONBF, 0);
    n = read(0, buf, sizeof buf);
    printf("%d\n", n);
    if (n < 0)
        printf("%d\n", errno);
    return 0;

This program will output -1 and 12 when running on my Windows 2000 box. Changing 30705 to 30704 will make it work. Uncommenting the line setvbuf has no effects. Building with MSVC 6 has the identical ouput.

Interesting error, "Not enough space"! The maximum limit for NT4 cmd.exe is 30698. As Luke pointed out, this doesn't happen with the MSYS console. I was asking about setvbuf because it sets the iostream to nonbuffered. Ironic though, the Run-Time Library Reference manual uses 60000 in the _read() example.

Since I had MSVC and the CRT source, I tried tracing into read(), and found the failure occurred at the following line:

  if ( !ReadFile( (HANDLE)_osfhnd(fh), buffer, cnt, (LPDWORD)&os_read,
                  NULL ) )

So the problem seems to be in the OS level? I cannot dig more since I do not have the source of ReadFile().

Seems more to be a problem with cmd.exe.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]