Analysis of the problem of using exec initiated process in TCL to occupy socket port

Source: Internet
Author: User
Tags socket

There is an integrated TCL interpreter program (called TT bar) to execute a script with exec to start a process (PP), the TT itself creates a socket port to communicate with other programs. At this point, the shutdown tt,pp is still running, use Netstat to view the port number, discover that the port number created by TT still exists, and that the port number cannot be created again. Note The port is not closed, but TT has exited, very strange. Then we look at the exec implementation and find that the process is created using CreateProcess, whose fifth parameter is to set the inheritance handle, which is unconditionally set to true in the exec implementation. This should be the reason, socket handle quilt process inherited, handle is the resources of the operating system, pp does not exit of course will not be released, so the TT created socket port has been occupied.

From the above question think about the things to note when using CreateProcess, if you do not need to continue the parent process handle do not set to true, so as not to create unnecessary trouble. At the same time, the general boot process can also use a few simple APIs, such as Winexec,shellexecute.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.