Todo:golang Linux Process exit description

Source: Internet
Author: User

Todo:golang Linux Process exit description

Golang using the Os.exit (code) process to exit causes the current program to exit and return the given status code. Traditionally, code codes of zero indicate a successful exit, and a non-0 error exits.

Syscall. Exit can invoke the exit of the operating system for different platforms.

The code value is 0-255, and when code is not 0 o'clock, the OS. Exit (code) will return, corresponding to the worth Status code

Exit Status 128

When code is 0, it exits normally. The code value can be customized to use the appropriate business scenario for the purpose. The value of code is cycled from a multiple of 0 to 255, such as a natural number of 256, when the process exits, the 0;256-511== code value is 0-255, the negative number is the same, 256 to -1== "0-255."

Exit code is the use of the situation, under the use of Linux most vividly

0 Command completed successfully

1 Common Unknown errors

2 Misuse of SHELL commands

126 command failed to execute

127 no Command found

128 Invalid Exit parameters

+X uses Linux signal x for fatal errors.

130 commands terminated with CTRL-C

255 exit status outside the specification

echo $? is the exit code that outputs the last command, and we see that 0,126,127 is what we expected. This is the use of the exit code under Linux, and our own software can also be self-defined.

Wxgzh:ludong86

Todo:golang Linux Process exit description

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.