delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/05/15/11:22:31

X-Spam-Check-By: sourceware.org
Message-ID: <44689C8D.A2E6459C@dessent.net>
Date: Mon, 15 May 2006 08:21:49 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: rvxt-20050409-1 console problem
References: <Pine DOT GSO DOT 4 DOT 63 DOT 0605151043130 DOT 26103 AT access1 DOT cims DOT nyu DOT edu> <e4a52n$9s9$1 AT sea DOT gmane DOT org>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k4FFMREk006084

Sven Köhler wrote:

> AFAIK, there are EXE-files that open a console, and others, that don't.
> 
> It seems, there is a flag in the EXE-files, which determines if Windows
> should open a console or not.

It is the "subsystem" flag in the PE header.  This can be set by adding
-Wl,--subsystem,windows (aka -Wl,-mwindows) or -Wl,--subsystem,console
(aka -Wl,-mconsole).

<http://msdn.microsoft.com/library/en-us/vccore/html/_core_.2f.SUBSYSTEM.asp>

> So i always was annoyed by the fact, that starting rxvt directly from
> windows opens a console windows.

Use 'run'.  Or, modulo the bug Igor is reporting, the latest refresh of
rxvt.

> Isn't it possible, to create such an EXE-file, that doesn't open a
> console? Would that cause any problems with cygwin?
> 
> That would make any "hide the console"-code unnecessary.

This is not an option in the slightest.  A -mwindows application cannot
interact with the console it was invoked from!  That means that all such
compiled applications would have no I/O when invoked from the command
line unless redirected to a file.  Try compiling "int main() {
puts("hello world"); }" with -mwindows and running it from a windows
console -- you get nothing.  -mwindows applications are expected to
either have no console I/O or to explicitly create a new console
themselves.  What isn't possible is to attach to the existing console
that it was run from.

Note that I said *windows console*.  This means from within CMD.EXE,
without $CYGWIN=tty.  If $CYGWIN=tty or you run from rxvt, xterm, over
ssh, then you're using a pty, which is different than a windows console,
and so the discussion is irrelevant.

Note also that Microsoft added an API call in XP and later that lets a
-mwindows compiled application attach to the existing console it was
spawned in.  This would allow the desired behavior (no new console
created, but still able to interact with the existing one) but this
would leave all users of nt/2k in the cold -- not an option.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


- Raw text -


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