Dear Tony,

Am 21.10.2011 16:15, schrieb Tony Mechelynck:
Dos-style shells (COMMAND.COM, NDOS.COM, 4DOS.COM, cmd.exe, 4NT.EXE,
etc.) open three handles (sysin, sysout and syserr) before starting a
program, and they expect those same three handles still to be open
when the program exits. They don't have to point to three different
files or devices: in the most usual case, all three point to the CON
device i.e. the console keyboard-and-screen device. This is when
starting a "console" application — IIUC, a GUI application is started
with no stdout or stderr unless a >> > or | redirection was explicitly
specified on the command-line (I'm not sure about stdin) and its I/O
is handled differently. For instance it is a known fact that in
Windows cmd.exe "firefox -help" (without the quotes) displays nothing
but "firefox -help |more" (still without the quotes) displays the
desired help.

thank you very much for your insightful answer!

However, there are two more things that I don't understand in the face of your reply.

1) The following code exits peacefully (with $?==0) if compiled under either MinGW or MSYS, how can that be?

#include <stdio.h>

int main (void)
{
        fclose(stdin);
        fclose(stdout);
        fclose(stderr);
        return 0;
}

2) Vim starts fine if the sh.exe found in PATH is a copy of zsh.exe from UnxUtils (but vim complains about "E79: Cannot expand wildcards" then), but it chrashes if it's bash.exe from MSYS, why?

Well, the code discussed here is in the child process of a fork() executed earlier. Maybe the culprit is in the parent process, but I haven't seen it so far...

 - Fabian

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui