unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: asynchronous process management on WinWP; buffering problem?
       [not found]         ` <u8xq7jizt.fsf@jasonrumney.net>
@ 2006-04-15 15:26           ` Lennart Borgman
  2006-04-15 17:54             ` Benjamin Riefenstahl
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2006-04-15 15:26 UTC (permalink / raw)
  Cc: help-gnu-emacs, Emacs Devel

Jason Rumney wrote:
> Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>
>   
>> Can Emacs then tell _isatty that it is a terminal? Or what does Emacs
>> do to handle this?
>>
>>
>> Note: It looks like the POSIX name now is _isatty.
>>     
>
> Probably not on Windows, since windows isn't POSIX and any POSIX layer
> that MingW32 has is unlikely to add functionality that is not already
> possible through other Windows APIs. On Windows stdout uses completely
> different API calls than console I/O.
>   
It actually seems like is _isatty is defined in MinGW. I just tested a 
small program I found here:

    http://permalink.gmane.org/gmane.comp.gnu.mingw.msys/448

    #include <stdio.h>

    int main(int argc, char *argv[])
    {
      if (isatty(fileno(stdin)) && _isatty(fileno(stdout)))
        printf("interactive\n");
      else
        printf("batch\n");
      return 0;
    }

If I run this program in cmd.exe it says "interactive". I get the same 
result under MSYS and Cygwin. However running it in Emacs in shell:

    M-x shell

it instead says "batch". (This is in the CVS version of Emacs.) Is this 
what is expected?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asynchronous process management on WinWP; buffering problem?
  2006-04-15 15:26           ` asynchronous process management on WinWP; buffering problem? Lennart Borgman
@ 2006-04-15 17:54             ` Benjamin Riefenstahl
  2006-04-15 23:50               ` Lennart Borgman
  0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Riefenstahl @ 2006-04-15 17:54 UTC (permalink / raw)
  Cc: help-gnu-emacs, Jason Rumney, Emacs Devel

Hi Lennart,


Lennart Borgman writes:
> It actually seems like is _isatty is defined in MinGW. I just tested
> a small program I found here:

The function isatty is defined in the Microsoft C runtime, and that is
what Mingw uses.  This version of isatty determines if a program is
running with stdin/stdout connected to an MS Windows console.

The way that consoles are implemented and used in MS Windows makes it
very complicated to use the console API to simulate a terminal in
Emacs.  On Unix-like systems this is done by so-called "pseudo-ttys",
"pty", but the MS Windows consoles are quite different beasts at the
OS API level.  Emacs would have to do a large amount of
reverse-engineering of the intent of the child process, to do with
consoles what Emacs does quite naturally on Unix with pseudo-ttys, and
there would still be features missing.  Therefore Emacs just uses
anonymous pipes instead which are a much better fit for the way Emacs
treats child processes, but that means that it can't make isatty in
child processes return true.

Cygwin can implement pseudo-ttys if it controls the parent as well as
the child, e.g. when you call a Cygwin program from a Cygwin compiled
Emacs.  It uses its own conventions to do that which are not
understood by non-Cygwin programs.


Sometimes you have a program that uses isatty to determine if it
should work in interactive mode or not, like the command shells of a
programming language or the some SQL interpreters.  In those cases you
will need to find a way put it into interactive mode without the help
of isatty.  Sometimes the shell will have a command-line option for
that, in other cases it can be configured after its start.


benny

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asynchronous process management on WinWP; buffering problem?
  2006-04-15 17:54             ` Benjamin Riefenstahl
@ 2006-04-15 23:50               ` Lennart Borgman
  2006-04-17 13:08                 ` Benjamin Riefenstahl
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2006-04-15 23:50 UTC (permalink / raw)
  Cc: help-gnu-emacs, Jason Rumney, Emacs Devel

Hi Benny,

Thanks for the good explanation. Indeed it looks difficult to fix this 
on the w32 platform. In my opinion w32 does not look very much POSIX 
conformant here. Or the POSIX specs are just too weak.


Benjamin Riefenstahl wrote:
> The function isatty is defined in the Microsoft C runtime, and that is
> what Mingw uses.  This version of isatty determines if a program is
> running with stdin/stdout connected to an MS Windows console.
>
> The way that consoles are implemented and used in MS Windows makes it
> very complicated to use the console API to simulate a terminal in
> Emacs.  On Unix-like systems this is done by so-called "pseudo-ttys",
> "pty", but the MS Windows consoles are quite different beasts at the
> OS API level.  Emacs would have to do a large amount of
> reverse-engineering of the intent of the child process, to do with
> consoles what Emacs does quite naturally on Unix with pseudo-ttys, and
> there would still be features missing.  Therefore Emacs just uses
> anonymous pipes instead which are a much better fit for the way Emacs
> treats child processes, but that means that it can't make isatty in
> child processes return true.
>
> Cygwin can implement pseudo-ttys if it controls the parent as well as
> the child, e.g. when you call a Cygwin program from a Cygwin compiled
> Emacs.  It uses its own conventions to do that which are not
> understood by non-Cygwin programs.
>
>
> Sometimes you have a program that uses isatty to determine if it
> should work in interactive mode or not, like the command shells of a
> programming language or the some SQL interpreters.  In those cases you
> will need to find a way put it into interactive mode without the help
> of isatty.  Sometimes the shell will have a command-line option for
> that, in other cases it can be configured after its start.
>
>
> benny
>   

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asynchronous process management on WinWP; buffering problem?
  2006-04-15 23:50               ` Lennart Borgman
@ 2006-04-17 13:08                 ` Benjamin Riefenstahl
  2006-04-17 16:02                   ` Lennart Borgman
  0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Riefenstahl @ 2006-04-17 13:08 UTC (permalink / raw)
  Cc: help-gnu-emacs, Emacs Devel

Hi Lennart, 


Lennart Borgman writes:
> In my opinion w32 does not look very much POSIX conformant here. Or
> the POSIX specs are just too weak.

POSIX specifies behaviour of Unix-like systems.  MS Windows doesn't
care about POSIX and Microsoft never said that it wanted to be
POSIX-compatible.

Don't confuse this with NT's POSIX subsystem.  This is a separate OS
running on top of the same NT kernel in parallel to MS Windows.  While
this is nominally a complete POSIX system, it used to be lacking some
stuff that is usually considered essential by Unix hackers, but not
specified or (officially) optional in POSIX.  Also Microsoft's support
for this is wavering, e.g. it is not supported on XP.


benny

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asynchronous process management on WinWP; buffering problem?
  2006-04-17 13:08                 ` Benjamin Riefenstahl
@ 2006-04-17 16:02                   ` Lennart Borgman
  0 siblings, 0 replies; 5+ messages in thread
From: Lennart Borgman @ 2006-04-17 16:02 UTC (permalink / raw)
  Cc: help-gnu-emacs, Emacs Devel

Benjamin Riefenstahl wrote:
> Hi Lennart, 
>
>
> Lennart Borgman writes:
>   
>> In my opinion w32 does not look very much POSIX conformant here. Or
>> the POSIX specs are just too weak.
>>     
>
> POSIX specifies behaviour of Unix-like systems.  MS Windows doesn't
> care about POSIX and Microsoft never said that it wanted to be
> POSIX-compatible.
>
> Don't confuse this with NT's POSIX subsystem.  This is a separate OS
> running on top of the same NT kernel in parallel to MS Windows.  While
> this is nominally a complete POSIX system, it used to be lacking some
> stuff that is usually considered essential by Unix hackers, but not
> specified or (officially) optional in POSIX.  Also Microsoft's support
> for this is wavering, e.g. it is not supported on XP.
>
>
> benny
>   
Hi Benny,

Thanks for the clarifications. What made me upset before was that MS 
claims that the _isatty API is POSIX compliant while MS does not give a 
way for programs (mostly shells I guess) to tell they are tty:s. (I 
guess my words here are much to inexact, but I hope you understand what 
I mean).

I mean that if they can get away with that then it seems like the 
specifications of _isatty is too weak.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-04-17 16:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <10m877fael0h3.1kg7y6ljn4qmb$.dlg@40tude.net>
     [not found] ` <443fdf5c$1@kcnews01>
     [not found]   ` <mailman.414.1145041920.9609.help-gnu-emacs@gnu.org>
     [not found]     ` <877j5r3ogd.fsf@catnip.gol.com>
     [not found]       ` <mailman.434.1145085136.9609.help-gnu-emacs@gnu.org>
     [not found]         ` <u8xq7jizt.fsf@jasonrumney.net>
2006-04-15 15:26           ` asynchronous process management on WinWP; buffering problem? Lennart Borgman
2006-04-15 17:54             ` Benjamin Riefenstahl
2006-04-15 23:50               ` Lennart Borgman
2006-04-17 13:08                 ` Benjamin Riefenstahl
2006-04-17 16:02                   ` Lennart Borgman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).