473,785 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.St art, 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

Nov 17 '05 #1
3 4536

"Wizou" <Wi*****@gmail. com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
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.St art, 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


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.
Nov 17 '05 #2
Well,

Under Windows API, you could specify, either through
SECURITY_ATTRIB UTES 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

Nov 17 '05 #3
Inline

Willy.
"Wizou" <Wi*****@gmail. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Well,

Under Windows API, you could specify, either through
SECURITY_ATTRIB UTES or through a parameter to CreateProcess if your
child processes would inherit open handles or not.
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_ATTRIB UTES have nothing to do with this.
I haven't find a way to do so under .NET. If you need this you wil have to call CreateProcess using PInvoke.
I find it a security hole that child process always have access to the
father process' handles. What makes you think it's a security hole?
(and UseShellExecute = true disables some features interesting to the
father process) Not sure what features you mean here. > 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 No, the handle is created with the creation of the TcpClient object.

Olivier

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1818
by: Doug Wyatt | last post by:
So I'll preface this with the fact that I'm a UNIX developer by training and have just recently gotten in to C# development on Windows. I'm basically running in to a problem whereby I suspect something to do with process groups or threads and closeOnExec semantics (to speak in POSIX terms) is causing me a problem. I've got a windows service (let's call it "myService") that, among other things, does : onStart creates a TcpListener on a...
7
1831
by: w.monthard | last post by:
Hi, here is my trouble: I need to call 2 différents processes in a same dos window, the first one is needed for the 2nd, and I have to pass several different arguments to the 2nd. My problem is that there are as many dos windows as calls to "myProcess.start()", and I don't know how to do ... Anybody has an idea ?
1
1473
by: Filip De Backer | last post by:
Hi everybody, I want to run 4 processes, but one after each other. Now I have a program that runs the 4 processes at the same time. How can I do that? thanks a lot! Filip
0
1261
by: Wizou | last post by:
1. Create a TcpListener 2. Start a child Process 3. Kill the parent process => You can't bind to the port until you close the child process Variant : 3. Terminate normally the parent process => The parent process stays as "Running" until the child process is closed
4
3839
by: Mike Cooper | last post by:
There is something about inherited classes I evidently don't know... I wrote the following class: Class Class1 inherits System.Windows.Forms.DataGridTextBoxColumn End Class There is absolutely no added functionality to it.
8
6715
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and contains a few controls anchored to the sides of the form. "frmChild" inherits from "frmBase"... and the controls appear on the inherited form as expected. However things start going wrong when I place addition controls on the "frmChild" form. When I...
4
1457
by: Sebastian Böck | last post by:
Hello all, i have a view defined as a simple select of a table. This table is inherited by a couple of others. All entries belong to the child-tables. I also have an unconditional update rule on the view. If i do an update to the view, the update is rewritten to update the father-table.
14
2644
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming Language, but there isn't a detail and complete description on all the class members, aren't they important to class composing? Could you explain the special class behavior in detail? Thank you very much.
2
2079
by: rocco.rossi | last post by:
I'm using the Python processing module. I've just run into a problem though. Actually, it's a more general problem that isn't specific to this module, but to the handling of Unix (Linux processes) in general. Suppose for instance that for some reason or another, after forking several child processes, the main process terminates or gets killed (or segfaults or whatever) and the child processes are orphaned. Is there any way to automatically...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10090
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.