delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/12/26/21:15:38

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-Id: <3.0.5.32.20031226211336.00804140@incoming.verizon.net>
X-Sender: vze1u1tg AT incoming DOT verizon DOT net
Date: Fri, 26 Dec 2003 21:13:36 -0500
To: cygwin AT cygwin DOT com
From: "Pierre A. Humblet" <Pierre DOT Humblet AT ieee DOT org>
Subject: Re: Please try the latest snapshot -- it is close to cygwin 1.5.6
In-Reply-To: <20031226225959.GC15677@redhat.com>
References: <20031226204641 DOT GA46362839 AT hpn5170x> <20031224152951 DOT GA34487383 AT hpn5170x> <20031223222816 DOT GA23935 AT redhat DOT com> <20031224152951 DOT GA34487383 AT hpn5170x> <3 DOT 0 DOT 5 DOT 32 DOT 20031224181524 DOT 007c21c0 AT incoming DOT verizon DOT net> <20031224232759 DOT GA12748 AT redhat DOT com> <20031226204641 DOT GA46362839 AT hpn5170x>
Mime-Version: 1.0

At 05:59 PM 12/26/2003 -0500, Christopher Faylor wrote:
>
>I added strace debugging.  You can use that as a clue for what I was
>talking about and make it visible if you can't run exim under strace.

I put a try_to_debug(1). Waiting for something to happen.


>>Also, while running sysinternals I noticed to the exim daemon still had tty
>>related handles, despite setsid(). Ditto for inetd.
>
>Calling setsid does not automatically eliminate tty handles.
>

This is what inetd does:
	if (setsid() == -1)
		return (-1);

	if (!noclose && (fd = open(PATH_DEVNULL, O_RDWR, 0)) != -1) {
		(void)dup2(fd, STDIN_FILENO);
		(void)dup2(fd, STDOUT_FILENO);
		(void)dup2(fd, STDERR_FILENO);
*******
Before your last changes, strace was showing 
  160  282749 [main] inetd 34569887 close: close (2)
  361  283110 [main] inetd 34569887 fhandler_tty_slave::close: decremented open_fhs 0, archetype usecount 2
  198  283308 [main] inetd 34569887 fhandler_tty_slave::close: just exiting because archetype usecount is > 0
  163  283471 [main] inetd 34569887 close: 0 = close (2)
  160  283631 [main] inetd 34569887 dtable::dup2: 2 = dup2 (3, 2)
*******

Now usecount is even higher

  159  292878 [main] inetd 1086339 close: close (2)
  181  293059 [main] inetd 1086339 fhandler_tty_slave::close: decremented open_fhs 0, archetype usecount 3
  313  293372 [main] inetd 1086339 fhandler_tty_slave::close: just returning because archetype usecount is > 0
  175  293547 [main] inetd 1086339 close: 0 = close (2)
  158  293705 [main] inetd 1086339 dtable::dup2: 2 = dup2 (3, 2)


I looked at your latest change in syscalls.cc. 
It seems to me that setsid should simply call close all the time if (cygheap->ctty)
and let close() take care of usecount.
Ditto in pinfo::set_ctty where a problem similar to the one you addressed also exists.

I don't think that will take care of everything, but I can't follow what's happening
when tracing sh -c inetd

Usecount jumps by 2 when open_fhs goes up by 1.

  179  854139 [main] SH 34649867 fhandler_tty_slave::open: /dev/tty1 opened, incremented open_fhs 3, archetype usecount 4

  237  880231 [main] sh 34649867 fhandler_tty_slave::dup: incremented open_fhs 4, archetype usecount 6

The trace is on http://mysite.verizon.net/phumblet/trace if interested.

Pierre


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019