Subject: Re: Xemacs/cygwin 21.4.3 and new console window during compilation
From: Andy Piper <[email-masked]>
To: Dmitry Bely <[email-masked]>, [email-masked]
Cc: [email-masked], [email-masked]
Date: Mon, 17 Dec 2001 18:33:14 -0800

So my supposition is that a console window is created because XEmacs 
doesn't have one by default when started from the desktop. The reason it 
works in bash is that children inherit their parent's console by default 
and somewhere up the foodchain cygwin has a console. I have no idea how we 
could fix this. I imagine that if we do AllocConsole in the cygwin version 
of XEmacs that whilst this may stop your program creating a console we will 
get an ugly console popping up for XEmacs as a whole. Maybe this is 
acceptable, I don't know. I'm CC'ing ben and the cygwin list to see if any 
windows gurus have any great ideas on this score.

andy

At 07:56 PM 7/3/2001 +0400, Dmitry Bely wrote:
>I have found very strange thing, which is the real showstopper for me. I
>cannot use ocaml compiler (www.ocaml.org) within Xemacs -- when it's called
>during compilation, new console window is always created and so
>warning/error messages are not catched by XEmacs compilation
>process. Having spent enough time, I've managed to extract from ocaml
>sources the following small test example, that demonstrates the problem:
>
>[---hello.c---]
>#include <stdio.h>
>
>int main()
>{
>   printf("Hello, world!\n");
>   printf("press any key...");
>   getchar();
>   return 0;
>}
>[---end of hello.c---]
>
>[---hello-run.c---]
>#pragma comment(linker , "/subsystem:console")
>
>#include <windows.h>
>
>#define msg_and_length(msg) msg , (sizeof(msg) - 1)
>const char* app = ".\\hello.exe";
>
>void main()
>{
>   STARTUPINFO stinfo;
>   PROCESS_INFORMATION procinfo;
>   DWORD retcode;
>
>   stinfo.cb = sizeof(stinfo);
>   stinfo.lpReserved = NULL;
>   stinfo.lpDesktop = NULL;
>   stinfo.lpTitle = NULL;
>   stinfo.dwFlags = 0;
>   stinfo.cbReserved2 = 0;
>   stinfo.lpReserved2 = NULL;
>
>   if (!CreateProcess(app, NULL, NULL, NULL, TRUE, 0, NULL, NULL,
>                      &stinfo, &procinfo)) {
>     HANDLE errh;
>     DWORD numwritten;
>     errh = GetStdHandle(STD_ERROR_HANDLE);
>     WriteFile(errh, msg_and_length("Cannot exec "), &numwritten, NULL);
>     WriteFile(errh, app, strlen(app), &numwritten, NULL);
>     WriteFile(errh, msg_and_length("\r\n"), &numwritten, NULL);
>     ExitProcess(2);
>#if _MSC_VER >= 1200
>     __assume(0); /* Not reached */
>#endif
>   }
>   CloseHandle(procinfo.hThread);
>   WaitForSingleObject(procinfo.hProcess , INFINITE);
>   GetExitCodeProcess(procinfo.hProcess , &retcode);
>   CloseHandle(procinfo.hProcess);
>   ExitProcess(retcode);
>#if _MSC_VER >= 1200
>     __assume(0); /* Not reached */
>#endif
>}
>[---end of hello-run.c---]
>
>Compile both files with MCVS 6.0:
>
>cl hello.c
>cl hello.run
>
>and run resulting hello-run.exe. If you do it via XEmacs shell/compile
>process, new Win32 console window will popup.
>
>Very doubtful that it's cygwin problem, because if hello-run.exe is
>executed from cygwin's sh or bash, new console is not created.
>
>My configuration:
>XEmacs 21.4.3/cygwin (latest binary distribution)
>Cygwin1.dll 1.3.2-1 (latest binary distribution)
>CYGWIN=tty binmode ntsec
>Windows NT 4.0 sp6a
>MSVC 6.0 sp5
>
>Can you reproduce that? Do you have any idea how it can be fixed?
>
>Hope to hear from you soon,
>Dmitry

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/