How can I use C to Prevent Abnormal Program exit when the system is closed?

Source: Internet
Author: User
How can I use C to Prevent Abnormal Program exit when the system is closed? -- Linux general technology-Linux programming and kernel information. The following is a detailed description. Question 1:
A server login program. Due to program problems, the login program cannot exit normally from the server when the system is closed. The server will prompt repeated logon when you log on again.
How can I capture the System Shutdown signal in the program and exit the server normally before the system is officially closed?
If yes, provide the sample code. Myself cainiao


Question 2:
For the same program, the executable file star and the configuration file star. conf (in the same directory) are used ). The executable file star to star. the access to conf is fp = fopen ("star. conf "," r "), so that I can only cd to the program directory to execute the program, or else the configuration file will not be found.
How can I obtain the executable program path (excluding the file name) in the program and synthesize the string with star. conf to obtain the correct access path of the configuration file?
If yes, provide the sample code. Myself cainiao

Question 3:
How to disable the current terminal in shell scripts? (Sh a script in a terminal. Close the terminal after the script is executed)

[ This post was last edited by the magic ghost at, September 10 ,.]

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.