zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: Peter Stephenson <pws@csr.com>
Cc: zsh-workers@sunsite.dk
Subject: Re: zpty woes
Date: Thu, 15 May 2008 15:50:54 +0100	[thread overview]
Message-ID: <20080515145054.GC5190@sc.homeunix.net> (raw)
In-Reply-To: <200805151318.m4FDIvKS015244@news01.csr.com>

On Thu, May 15, 2008 at 02:18:57PM +0100, Peter Stephenson wrote:
> Jaime Vargas wrote:
> > In the script attached, when trying to follwing line always fails.
> > 
> >      zpty -r scppty line "*:" || echo "no password asked" && exit
> > 
> > It appears that the "password" string from the ssh session is discarded
> > by the psuedo terminal.
> > 
> > Is there a way to fix this? or Am I missing something?
> 
> Yes and yes, but it's annoying and I spent a few minutes rediscovering
> the arcana.  zpty attempts to read in whole lines, while the password
> prompt isn't a whole line.  I came across this myself and looked at the
> code a while ago and it seemed unnecessarily obscure.  However, I worked
> around it and don't have time to make it work sensibly in all the
> possible cases, so I'm not touching it.  (If anyone's interested it's in
> ptyread() in Src/Modules/zpty.c and could definitely do with someone
> taking it over; it's pretty much self-contained.)
> 
> To work around this, you need to use non-blocking mode, i.e. start with
> "zpty -b scppty ...".  I think (although the code is obscure) that with
> your "*:" pattern this will work, i.e. although it doesn't block it will
> carry on reading until it gets the password input.  If not, you would
> need to delay (the zsh/zselect module allows you to do this in 100ths of
> a second) and retry.  (Waiting for a pattern with noblocking is
> effectively a busy wait so even this isn't ideal---you can add the -t
> option to the -r command line to test first, but then it *won't* wait
> if there's no input and you do have to delay in your script.)
[...]

It works for me without "-b", why would you say "-b" is
necessary?

The problem I've found is that zpty -r doesn't return when the
command in the pty has terminated. A strace -p shows:

read(12, 0xb7ba04c8, 1)                 = -1 EIO (Input/output error)
read(12, 0xb7ba04c8, 1)                 = -1 EIO (Input/output error)
read(12, 0xb7ba04c8, 1)                 = -1 EIO (Input/output error)
read(12, 0xb7ba04c8, 1)                 = -1 EIO (Input/output error)
read(12, 0xb7ba04c8, 1)                 = -1 EIO (Input/output error)
read(12, 0xb7ba04c8, 1)                 = -1 EIO (Input/output error)
read(12, 0xb7ba04c8, 1)                 = -1 EIO (Input/output error)
read(12, 0xb7ba04c8, 1)                 = -1 EIO (Input/output error)
read(12, 0xb7ba04c8, 1)                 = -1 EIO (Input/output error)
[...]

And the other problem I mentionned in another email about the
PS4 output not being correct.

-- 
Stéphane


  reply	other threads:[~2008-05-15 14:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 12:02 Jaime Vargas
2008-05-15 13:10 ` Stephane Chazelas
2008-05-15 13:18 ` Peter Stephenson
2008-05-15 14:50   ` Stephane Chazelas [this message]
2008-05-15 15:26     ` Peter Stephenson
2008-05-15 16:25     ` Jaime Vargas
2008-05-15 16:36       ` * " Peter Stephenson
     [not found]     ` <99E8D43E-EC34-48DB-A5AD-BFA197A3AAA3@mac.com>
2008-05-15 17:03       ` Stephane Chazelas
     [not found]       ` <480CEB80051F27AE@mac.com>
2008-05-15 17:38         ` Jaime Vargas
2008-05-15 17:53           ` Jaime Vargas
2008-05-20  3:25             ` Jaime Vargas
2008-05-20 14:28               ` zpty woes (enhancement request) Jaime Vargas
2008-05-20 16:25                 ` Bart Schaefer
2008-05-15 13:26 ` zpty woes Stephane Chazelas
2008-05-15 15:44   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080515145054.GC5190@sc.homeunix.net \
    --to=stephane_chazelas@yahoo.fr \
    --cc=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).