Subject: Re: socket/fdopen/exec problem
From: "Pierre A. Humblet" <[email-masked]>
To: Corinna Vinschen <[email-masked]>
Cc: cygwin <[email-masked]>
Date: Sat, 26 Jan 2002 23:51:38 -0500

At 05:10 PM 1/25/02 +0100, Corinna Vinschen wrote:
>On Fri, Jan 25, 2002 at 10:39:30AM -0500, Pierre A. Humblet wrote:

<snip, long example>
>> Any thoughts?
>
>Not immediately.  Two questions:
>
<snip, already answered>

>- Could you patch Cygwin fhandler_socket.cc, fhandler_socket::close()
>  and rip out the whole linger stuff so that only the naked closesocket()
>  call remains and see if that changes the behaviour?
>
Corinna,

No difference (on Win98 and Me. I will try NT on Monday).

I can now duplicate exactly what's happening in the application I am porting.
A key element is that it disconnects itself from the controlling terminal
by closing fd 0, 1 & 2 and forking. Weird things happen afterwards:
1) For every re-exec (triggered by -HUP), ps -W and the Windows task manager
   show an extra copy of the program.
   [without the disconnect from the controlling terminal, only one process
appears]
2) If a tcp call was received and a child was forked, then after the next
re-exec
   netstat -a shows an extra LISTEN on port 999. It never goes away. This
happens
   even if the -HUP is given long after (I tried up to 5 minutes) the child
   terminates. Eventually incoming calls are not answered.
   [without the disconnect from the controlling terminal, an extra LISTEN
appears 
    only if the -HUP was given while the child is running, and it
disappears when 
    the child exits]
I have no idea where to start debugging that. I am attaching the demo program.
It is used as shown in the previous message, and also using ps -W. 

Ntsec good news: I think I have identified and solved the problem of
having an incorrect UID, and also of setting the DACL in the token security
descriptor. I will test on Monday and let you know.

Pierre

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/