zsh-workers
 help / color / mirror / code / Atom feed
* RE: PATCH: Re: zpty and controlling tty (and other fd's)
@ 2000-05-04 13:33 Sven Wischnowsky
  2000-05-04 13:48 ` nslookup (function) problem Andrej Borsenkow
  2000-05-05 16:57 ` PATCH: Re: zpty and controlling tty (and other fd's) Andrej Borsenkow
  0 siblings, 2 replies; 10+ messages in thread
From: Sven Wischnowsky @ 2000-05-04 13:33 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > On True64 Unix O_NOCTTY is implicit and cannot be unset. How weird.
> 
> Hmm ... if I correctly recall, first tty opened by process becomes
> controlling tty. It means, that if child has closed all of it's file
> descriptors and reopens tty for stdin (duplicating it for stdout,
> stderr) - it gets it as controlling tty. It should be fairly portable.

What I said with the above is that on True64 Unix opening a terminal
in a process with no controlling tty does *not* make that terminal the 
controlling tty of the process.

So: `how weird'.

> ...
> 
> Note fd's 3 and 13. 3 is master side of pty (child does not need it,
> does it?)

Of course I tried to close it -- and on Linux this messed up the
parent's (i.e. the shell's) terminal settings. Don't know how this
came.

> And 13 is left over from wordcode file mapping. Mapping itself
> goes away after exec (at least here - I expect, it should be true for
> all Unices) - but we have to close fd anyway.

Ah, right. I don't use wordcode files in development versions.


This adds the closedumps() function and makes it be called in zpty.c
and zexecve(). Does anyone know of other places where it should be
called?


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* nslookup (function) problem
  2000-05-04 13:33 PATCH: Re: zpty and controlling tty (and other fd's) Sven Wischnowsky
@ 2000-05-04 13:48 ` Andrej Borsenkow
  2000-05-05 16:57 ` PATCH: Re: zpty and controlling tty (and other fd's) Andrej Borsenkow
  1 sibling, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 2000-05-04 13:48 UTC (permalink / raw)
  To: zsh-workers

With the latest Zsh (and no special settings apart PAGER=less):

bor@itsrm2% command nslookup
Default Server:  mowd017a.mow.siemens.ru
Address:  139.24.18.1

> ?
# @(#)nslookup.help     Revision: 3.1   92/09/23 13:57:57
#
# @(#)nslookup.help     Revision: 2.2   91/06/06 17:41:55
#
Commands:       (identifiers are shown in uppercase, [] means optional)
NAME            - print info about the host/domain NAME using default
server
NAME1 NAME2     - as above, but use NAME2 as server
help or ?       - print info on common commands; see nslookup(1) for
details
set OPTION      - set an option
    all         - print options, current server and host
    [no]debug   - print debugging information
    [no]d2      - print exhaustive debugging information
    [no]defname - append domain name to each query
    [no]recurse - ask for recursive answer to query
    [no]vc      - always use a virtual circuit
    domain=NAME - set default domain name to NAME
    srchlist=N1[/N2/.../N6] - set domain to N1 and search list to N1,N2,
etc.
    root=NAME   - set root server to NAME
    retry=X     - set number of retries to X
    timeout=X   - set initial time-out interval to X seconds
    querytype=X - set query type, e.g.,
A,ANY,CNAME,HINFO,MX,NS,PTR,SOA,WKS
    type=X      - synonym for querytype
    class=X     - set query class to one of IN (Internet), CHAOS, HESIOD
or ANY
/usr/lib/named/nslookup.help 62%
....

that is , it runs help output through pager (`less' in my case).

Unfortunately, function nslookup hangs completely in this case:

bor@itsrm2% autoload -U nslookup
bor@itsrm2% nslookup
Default Server:  mowd017a.mow.siemens.ru
Address:  139.24.18.1

> ?
nothing comes here; it habgs; it is no more possible to kill it with ^C,
^\ or ^Z.

-andrej


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

* RE: PATCH: Re: zpty and controlling tty (and other fd's)
  2000-05-04 13:33 PATCH: Re: zpty and controlling tty (and other fd's) Sven Wischnowsky
  2000-05-04 13:48 ` nslookup (function) problem Andrej Borsenkow
@ 2000-05-05 16:57 ` Andrej Borsenkow
  1 sibling, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 2000-05-05 16:57 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

> >
> > Note fd's 3 and 13. 3 is master side of pty (child does not need it,
> > does it?)
>
> Of course I tried to close it -- and on Linux this messed up the
> parent's (i.e. the shell's) terminal settings. Don't know how this
> came.
>

Well, at least Midnight and Screen do it - so, it is possible. This one
is from Midnight code that spawns subshell. I do not know, how usefulr
it is.

        /* {{{ Open the slave side of the pty: again */
        pty_slave = pty_open_slave (pty_name);

        /* This must be done before closing the master side of the pty,
*/
        /* or it will fail on certain idiotic systems, such as Solaris.
*/

        /* Close master side of pty.  This is important; apart from
*/
        /* freeing up the descriptor for use in the subshell, it also
*/
        /* means that when MC exits, the subshell will get a SIGHUP and
*/
        /* exit too, because there will be no more descriptors pointing
*/
        /* at the master side of the pty and so it will disappear.
*/

        close (subshell_pty);


I do not use Linux, but until this is cleared there - porbably under
#ifndef __LINUX (or whatever)?

-andrej


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

* Re: nslookup (function) problem
  2000-05-05  8:47 Sven Wischnowsky
  2000-05-05  8:55 ` Peter Stephenson
@ 2000-05-05 14:53 ` Bart Schaefer
  1 sibling, 0 replies; 10+ messages in thread
From: Bart Schaefer @ 2000-05-05 14:53 UTC (permalink / raw)
  To: zsh-workers

On May 5, 10:47am, Sven Wischnowsky wrote:
} Subject: RE: nslookup (function) problem
}
} This adds the `pager' style.
} 
} +typeset +g -x PAGER=cat

Hey, look, a reason to export a local.  Peter's effort was not in vain.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* RE: nslookup (function) problem
  2000-05-05  8:55 Sven Wischnowsky
@ 2000-05-05 10:01 ` Andrej Borsenkow
  0 siblings, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 2000-05-05 10:01 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

> +  if [[ -n "$pager" && ${#${(f)line}} -gt LINES ]]; then
> +    print -nr "$line" | "$pager"

:-)))

bor@itsrm2% export PAGER='less -c'
bor@itsrm2% nslookup
Default Server:  mowd017a.mow.siemens.ru
Address:  139.24.18.1

> ?
nslookup:37: command not found: less -c
> 

-andrej


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

* RE: nslookup (function) problem
@ 2000-05-05  8:55 Sven Wischnowsky
  2000-05-05 10:01 ` Andrej Borsenkow
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 2000-05-05  8:55 UTC (permalink / raw)
  To: zsh-workers


Err, sorry, I applied a slightly different patch that pages only if
there are more lines than fit on the screen.
I wrote:

Bye
 Sven

Index: Functions/Misc/nslookup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Misc/nslookup,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 nslookup
--- Functions/Misc/nslookup	2000/03/10 01:01:03	1.1.1.9
+++ Functions/Misc/nslookup	2000/05/05 08:45:38
@@ -4,6 +4,8 @@
 setopt localoptions localtraps completealiases
 
 local tmp line compcontext=nslookup curcontext='nslookup:::' pmpt
+local pager opager="$PAGER"
+typeset +g -x PAGER=cat
 
 zmodload -e zsh/zpty || zmodload -i zsh/zpty
 
@@ -13,6 +15,8 @@
 pmpt=()
 zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
 zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
+zstyle -s ':nslookup' pager tmp &&
+    [[ -z "$pager" ]] && pager="${opager:-more}"
 (( $#pmpt )) || pmpt=(-p '> ')
 
 zpty nslookup nslookup
@@ -29,7 +33,11 @@
 
   zpty -r nslookup line '*
 > '
-  print -nr "$line"
+  if [[ -n "$pager" && ${#${(f)line}} -gt LINES ]]; then
+    print -nr "$line" | "$pager"
+  else
+    print -nr "$line"
+  fi
 done
 
 zpty -w nslookup 'exit'

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: nslookup (function) problem
  2000-05-05  8:47 Sven Wischnowsky
@ 2000-05-05  8:55 ` Peter Stephenson
  2000-05-05 14:53 ` Bart Schaefer
  1 sibling, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 2000-05-05  8:55 UTC (permalink / raw)
  To: Zsh hackers list

>  zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
>  zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
> +zstyle -s ':nslookup' pager tmp &&

Just noticed the contexts here are different with what I added for zftp,
which are ':zftp:zfopen:' and so on, with a colon at the end.  I suppose
the obvious answer is that I should delete the final colon in that case.

-- 
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


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

* RE: nslookup (function) problem
@ 2000-05-05  8:47 Sven Wischnowsky
  2000-05-05  8:55 ` Peter Stephenson
  2000-05-05 14:53 ` Bart Schaefer
  0 siblings, 2 replies; 10+ messages in thread
From: Sven Wischnowsky @ 2000-05-05  8:47 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > - Does it use other environment variables? If so, which. In which
> >   order? I.e. which one overrides all others?
> > - If $PAGER is not set, does it use a default pager or does it just
> >   dump the help to the output? I.e. is it enough to locally unset
> >   PAGER in nslookup() or should we locally export PAGER=cat?
> >
> 
> Unsetting PAGER runs it through `more' (obviously, default - but this
> PAGER story is not documented anywhere). Setting PAGER=cat does the
> trick ... almost. The problem is, now the ability to page output is
> lost.
> 
> Hmm ... may be extend nslookup function in the same way (probably, using
> style to turn it on/off)? If output has more lines than fit on screen,
> run it through PAGER?

I was thinking about the same when I asked...

This adds the `pager' style. If set, it's value is used as the progrma 
to use for paging (and only then will paging be done at all). If the
value is the empty string, it uses $PAGER or `more' if $PAGER is not
set.


Bye
 Sven

Index: Functions/Misc/nslookup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Misc/nslookup,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 nslookup
--- Functions/Misc/nslookup	2000/03/10 01:01:03	1.1.1.9
+++ Functions/Misc/nslookup	2000/05/05 08:45:38
@@ -4,6 +4,8 @@
 setopt localoptions localtraps completealiases
 
 local tmp line compcontext=nslookup curcontext='nslookup:::' pmpt
+local pager opager="$PAGER"
+typeset +g -x PAGER=cat
 
 zmodload -e zsh/zpty || zmodload -i zsh/zpty
 
@@ -13,6 +15,8 @@
 pmpt=()
 zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
 zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
+zstyle -s ':nslookup' pager tmp &&
+    [[ -z "$pager" ]] && pager="${opager:-more}"
 (( $#pmpt )) || pmpt=(-p '> ')
 
 zpty nslookup nslookup
@@ -29,7 +33,11 @@
 
   zpty -r nslookup line '*
 > '
-  print -nr "$line"
+  if [[ -n "$pager" ]]; then
+    print -nr "$line" | "$pager"
+  else
+    print -nr "$line"
+  fi
 done
 
 zpty -w nslookup 'exit'

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* RE: nslookup (function) problem
  2000-05-04 14:49 nslookup (function) problem Sven Wischnowsky
@ 2000-05-05  8:23 ` Andrej Borsenkow
  0 siblings, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 2000-05-05  8:23 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

>
> - Does it use other environment variables? If so, which. In which
>   order? I.e. which one overrides all others?
> - If $PAGER is not set, does it use a default pager or does it just
>   dump the help to the output? I.e. is it enough to locally unset
>   PAGER in nslookup() or should we locally export PAGER=cat?
>

Unsetting PAGER runs it through `more' (obviously, default - but this
PAGER story is not documented anywhere). Setting PAGER=cat does the
trick ... almost. The problem is, now the ability to page output is
lost.

Hmm ... may be extend nslookup function in the same way (probably, using
style to turn it on/off)? If output has more lines than fit on screen,
run it through PAGER?

-andrej


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

* Re: nslookup (function) problem
@ 2000-05-04 14:49 Sven Wischnowsky
  2000-05-05  8:23 ` Andrej Borsenkow
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 2000-05-04 14:49 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> With the latest Zsh (and no special settings apart PAGER=less):
> 
> ...
>
> that is , it runs help output through pager (`less' in my case).
> 
> Unfortunately, function nslookup hangs completely in this case:
> 
> bor@itsrm2% autoload -U nslookup
> bor@itsrm2% nslookup
> Default Server:  mowd017a.mow.siemens.ru
> Address:  139.24.18.1
> 
> > ?
> nothing comes here; it habgs; it is no more possible to kill it with ^C,
> ^\ or ^Z.

More information would have been helpful here (my nslookup does not do 
such things):

- Does it use other environment variables? If so, which. In which
  order? I.e. which one overrides all others?
- If $PAGER is not set, does it use a default pager or does it just
  dump the help to the output? I.e. is it enough to locally unset
  PAGER in nslookup() or should we locally export PAGER=cat?

Could you please try?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

end of thread, other threads:[~2000-05-05 16:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-04 13:33 PATCH: Re: zpty and controlling tty (and other fd's) Sven Wischnowsky
2000-05-04 13:48 ` nslookup (function) problem Andrej Borsenkow
2000-05-05 16:57 ` PATCH: Re: zpty and controlling tty (and other fd's) Andrej Borsenkow
2000-05-04 14:49 nslookup (function) problem Sven Wischnowsky
2000-05-05  8:23 ` Andrej Borsenkow
2000-05-05  8:47 Sven Wischnowsky
2000-05-05  8:55 ` Peter Stephenson
2000-05-05 14:53 ` Bart Schaefer
2000-05-05  8:55 Sven Wischnowsky
2000-05-05 10:01 ` Andrej Borsenkow

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).