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 3 4476
"Wizou" <Wi*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.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.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
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.
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
Inline
Willy.
"Wizou" <Wi*****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com... 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.
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.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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
|
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...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |