The exit and exit status codes exit are used to end a script, just like in C. it also returns a value, which is passed to the parent process of the script. The parent process uses this value for further processing. each command returns an exit
Exit and exit Status Codes
Exit is used to end a script, just like in C. it also returns a value, which is passed to the parent process of the script. The parent process uses this value for further processing.
Each command returns an exit status
Linux Shell Bash with special meaning exit code purpose descriptionThe exit command exits the current shell and can terminate the current script execution in a shell script.Common parametersFormat: Exit nExit. Set the exit code to N. (cause the
Linux provides a special variable $ to save the exit status code of the last executed command. For commands that need to be checked, you must view or use the $? variable immediately after it has been run. Its value becomes the exit status code of
For more information about the list of all "script stories" columns, click here.
From: http://www.microsoft.com/china/technet/community/columns/scripts/sg0904.mspxContent on this page
The worm crawls in, but does not leave.
Original link: http://codingstandards.iteye.com/blog/836625 (reproduced please specify the source)Description of UseThe exit command exits the current shell and can terminate the current script execution in a shell script.Common parametersFormat:
General PracticeCat>test.SH"'#!/bin/Bashexit_script () {Exit1}Echo "before Exit"Exit_scriptEcho "After exit"EOFchmodA+x test.SH./test.SHEcho$?# output before exit1You can see that direct use exit can exit the script, and you can pass the error code
1. Graceful exit of the process 1.1.kill-9 PID problemsIt is easy and efficient to force a process to be killed by Kill-9 PID on Linux, so many program stop scripts often choose how to use the kill-9 PID.Whether the Kill-9 PID of Linux or the
Exit is used to end a script in which the script terminates immediately when the Exit command is encountered, and the terminating exit status depends on the number following the Exit command;Exit [n]: Custom exit status code;An example is described.1
Now I've written a Hello World program to take a look at it:
Filename:main.c
#include
int main (void)
{
printf ("Hello wolrd!\n");
return (-);
}
Compile execution: gcc main.c &&/a.out
Now let's take a look at the return
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.