search
Twitter Rss Feeds
MicrosoftArticlesForumsGroups
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml/Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsGroups
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsGroups
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsGroups
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsGroups
Microsoft Excel
Microsoft Word
Microsoft Powerpoint
Publisher
Money

Operating SystemsArticlesForumsGroups
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsGroups
Share Point
BizTalk
Site Server
Exhange Server
IIS
Transaction Server

Graphic DesignArticlesForumsGroups
Macromedia Flash
Adobe PhotoShop
Microsoft Expression

OtherArticlesForumsGroups
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Reviews
Search Engines
Resumes

 

Previous Thread:   Debugging DLLs

8/27/2005 3:38:53 PM    TcpListener inherited by child processes when UseShellExecute = false
i'm using .NET 2.0, and i've made a lot of tests  
  
i've come to the conclusion that TCP servers (tcplistener), started by  
  
a father process, are somewhat inherited by child processes if using  
  
UseShellExecute = false  
  
why is that ?  
  
try it ! even if the TcpListener is started *after* the  
  
childProcess.Start, the TCP server is still registered in netstat -ao  
  
and connectable with telnet, even if the father process stopped (or  
  
crashed, or was killed)  
  
As long as the child process is living, the TCP server is there, with  
  
the old PID of the father process  
  
When the child process ends, the TCP server disappears and telnet  
  
connection is stopped  
  
This is annoying because it prevent another app from listening on this  
  
port (for example, if you stopped debugging in Visual and you want to  
  
restart debugging your app)  
  
can someone explain this? or is this a bug of .NET 2.0 beta ?  
  
thanks

8/28/2005 6:29:03 AM    Re: TcpListener inherited by child processes when UseShellExecute = false
Well,  
  
Under Windows API, you could specify, either through  
  
SECURITY_ATTRIBUTES or through a parameter to CreateProcess if your  
  
child processes would inherit open handles or not.  
  
I haven't find a way to do so under .NET.  
  
I find it a security hole that child process always have access to the  
  
father process' handles.  
  
(and UseShellExecute = true disables some features interesting to the  
  
father process)  
  
I thought *starting* the TcpListener after the child process would be  
  
enough, but I also had to move the TcpListener object creation after  
  
it, in order to solve my problem  
  
Olivier

8/28/2005 1:34:02 PM    Re: TcpListener inherited by child processes when UseShellExecute = false
"Wizou" <Wizou95@gmail.com> wrote in message  
  
news:1125182333.683152.305460@g14g2000cwa.googlegroups.com...  
  
No, it's not a bug, it's by design.  
  
The child process inherits all open handles of the parent process when using  
  
Process.Start, this is the default and cannot be changed.  
  
You can prevent this by starting the child process before you create the  
  
TcpListerner object.  
  
Willy.

8/28/2005 8:22:51 PM    Re: TcpListener inherited by child processes when UseShellExecute = false
Inline  
  
Willy.  
  
"Wizou" <Wizou95@gmail.com> wrote in message  
  
news:1125235743.855582.203690@o13g2000cwo.googlegroups.com...  
  
That's right, it's the CreateProcess API argument bInheritHandles that  
  
specifies whether you want the child to inherit open handles and this is set  
  
to true in .NET, the SECURITY_ATTRIBUTES have nothing to do with this.  
  
If you need this you wil have to call CreateProcess using PInvoke.  
  
What makes you think it's a security hole?  
  
Not sure what features you mean here. >  
  
No, the handle is created with the creation of the TcpClient object.


Pete's Blog   |    Pete's Resume   |    Robbe's Blog   |    Robbe's Resume   |    Archive #2   |    Archive #3   |    Dotnetslackers   |    XmlPitStop   |    Advertise   |   Contact Us   |   Privacy   |   Copyright (c) 2000 - 2009 eggheadcafe.com  All rights reserved.