The patch seems to resolv the problem.

Only seems, because I only known to reproduce it for the 'tty' descriptor, but 
I hope the 'null' descriptor will be in the same case :-)

But I will use this version for test it.

Thanks a lot.
-- 
Sebastien Marie

On Wed, Sep 26, 2012 at 03:42:23PM +0100, Nicholas Marriott wrote:
> Try this please:
> 
> Index: server-client.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/tmux/server-client.c,v
> retrieving revision 1.79
> diff -u -p -r1.79 server-client.c
> --- server-client.c   3 Sep 2012 09:32:38 -0000       1.79
> +++ server-client.c   26 Sep 2012 14:42:04 -0000
> @@ -912,8 +912,10 @@ server_client_msg_identify(
>               return;
>       }
>  
> -     if (!isatty(fd))
> -         return;
> +     if (!isatty(fd)) {
> +             close(fd);
> +             return;
> +     }
>       data->term[(sizeof data->term) - 1] = '\0';
>       tty_init(&c->tty, c, fd, data->term);
>       if (data->flags & IDENTIFY_UTF8)
> 
> 
> On Wed, Sep 26, 2012 at 01:40:53PM +0200, S?bastien Marie wrote:
> > Hi,
> > 
> > After some tests (on a new tmux server, started with "tmux -L test ..."), I 
> > could (partially) reproduce the problem.
> > 
> > Partially, because:
> >  in fstat output there are 2 kinds of "bugged" entries: tty and null
> >   tty:  181 descriptors
> >   null: 320 descriptors
> > 
> > And I arrived to keep descriptors opened against /dev/tty , but not against 
> > /dev/null (for the moment, but I monitor what in my use what generate 
> > this...).
> > 
> > This occurs with urlview (textproc/urlview), with a custom url_handler.
> > 
> > Basically urlview take a text in stdin (generally an email), and display a 
> > menu (ncurses) of URLs found in the text. The user choose an URL, and 
> > urlview start a command (in my case, a custom script).
> > 
> > First, my configuration:
> > $ cat ~/.urlview
> > # command to invoke for selected URL
> > COMMAND /home/semarie/.local/bin/urlview_handler.sh
> > 
> > Next, the command started by urlview:
> > $ cat /home/semarie/.local/bin/urlview_handler.sh
> > #!/bin/sh
> > 
> > # if TMUX enable, update environment
> > if [ -n "${TMUX}" ] ; then
> >   eval  `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$/=\"\1\"/'`
> >   unset `tmux show-environment | grep    '^-' | sed 's/^-//'`
> >   export `tmux show-environment | grep -v '^-' | sed 's/=\(.*\)$//'`
> > fi
> > 
> > # check DISPLAY
> > if [ -n "${DISPLAY}" ] ; then
> >   exec chrome "$@"
> > fi
> > 
> > # if not DISPLAY
> > exec lynx "$@"
> > 
> > 
> > 
> > And when I launch the command:
> > $ echo 'http://www.openbsd.org/' | urlview
> > 
> > 3 new descriptors against "tty" are opened and not closed after the 
> > command. There are directly correlate with the 3 "tmux show-environment" in 
> > the script.
> > 
> > I don't remind exactly the purpose of updating the environnement in the 
> > script... should be to keep kerberos ticket or display environnement in 
> > text-mode ... but ?
> > 
> > Additionnaly, running the url_hander alone (without urlview) don't trigger 
> > the problem.
> > 
> > I will disabling the part of "updating environment" in my script (and if I 
> > always need it, I will recall when something won't work !)
> > 
> > I will post when I have more info.
> > 
> > Please let me known if more informations are needed.
> > 
> > Thanks.
> > -- 
> > Sebastien Marie

Reply via email to