From andrewi@harlequin.co.uk  Mon Jul  1 07:40:16 1996
X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
	[nil "Mon" " 1" "July" "1996" "15:38:42" "+0100" "Andrew Innes" "andrewi@harlequin.co.uk" nil "42" "Re: [gordonp@smtplink.indigo.co.il: Re[2]: Emacs and Perl bad interaction]" "^From:" nil nil "7" nil nil nil nil]
	nil)
Received: from holly.cam.harlequin.co.uk (holly.cam.harlequin.co.uk [193.128.4.58]) by june.cs.washington.edu (8.7.5/7.2ju) with SMTP id HAA05753 for <voelker@cs.washington.edu>; Mon, 1 Jul 1996 07:40:11 -0700
Received: from propos.long.harlequin.co.uk by holly.cam.harlequin.co.uk; Mon, 1 Jul 1996 15:40:06 +0100
Received: from woozle.long.harlequin.co.uk (woozle [193.128.93.77]) by propos.long.harlequin.co.uk (8.6.12/8.6.12) with SMTP id PAA24644; Mon, 1 Jul 1996 15:38:42 +0100
Message-Id: <199607011438.PAA24644@propos.long.harlequin.co.uk>
In-Reply-To: <199606300826.EAA02951@psilocin.gnu.ai.mit.edu> (message from 	Richard Stallman on Sun, 30 Jun 1996 04:26:22 -0400)
From: Andrew Innes <andrewi@harlequin.co.uk>
To: rms@gnu.ai.mit.edu
Cc: voelker@cs.washington.edu
Subject: Re: [gordonp@smtplink.indigo.co.il: Re[2]: Emacs and Perl bad interaction]
Date: Mon, 1 Jul 1996 15:38:42 +0100

On Sun, 30 Jun 1996 04:26:22 -0400, Richard Stallman <rms@gnu.ai.mit.edu> said:
>Is this the same problem with running DOS subprocesses that we already
>know about?

No, Perl is a native Win32 program.  I'd noticed a long time ago that
"perl -de 0" just seems to hang under Emacs, but never tried to
invesigate further.

The fault lies with Perl (indirectly with NT/Win95).

The problem is that the Perl debugger explicitly opens a connection to
"CON", which is the DOS/NT equivalent of "/dev/tty", for interacting
with the user.

On Unix, this is okay, because Emacs (or the shell?) creates a
pseudo-tty so that /dev/tty is really the pipe Emacs is using to
communicate with the subprocess.

On NT, this fails because CON always refers to the handle for the
relevant console (approximately equivalent to a tty), and cannot be
redirected to refer to the pipe Emacs assigned to the subprocess as
stdin.

[
This behaviour of NT causes problems with other programs as well - for
example, the standard ftp program on NT always prompts and reads the
password explicitly from CON, which means ange-ftp cannot work with it.

In the case of ange-ftp, we found the source for a POSIX ftp program
and replaced getpass with a version I wrote that doesn't do this.
]

In this case, there is a work-around.  The source for the Perl debugger
is included with Perl (lib/perldb.pl) - although it appears to prefer
having a separate channel for user interaction so as not to interfere
with the debuggee's use of STDIN/STDOUT, it will use STDIN/STDOUT if
necessary.  So, the user can modify perldb.pl to always use STDIN/STDOUT.

I've tested this briefly to verify that it works, at least for simple
things.

AndrewI

