[shell]脚本退出后,其调用的命令会如何样

[shell]脚本退出后,其调用的命令会怎么样?
假设我从脚本中调用了一些命令,当我的脚本通过exit 0退出后,那些被调用的命令会被结束么?
第一种情况:脚本调用了类似echo的命令,命令执行完毕后遇到exit 0,脚本退出,当然echo在这之前已经结束了。
第二种情况:脚本调用了类似ping的命令,ping命令没有结束前脚本是不会退出的,应该没错吧。
关键是第三种情况:脚本调用了可以一直在后台执行的命令,暂时没想到什么例子,这种情况下脚本会不会运行到exit 0这一步而退出呢?

...
...
ping www.baidu.com &
exit 0

这个例子能不能归类到第三种情况呢?
Thanks!

------解决思路----------------------
加了&就应该在后台运行
------解决思路----------------------
引用:
Quote: 引用:

Quote: 引用:

Quote: 引用:

加了&就应该在后台运行

&符号在脚本中也有用么?

脚本跟控制台输入的没什么区别,只是可以认为是批处理而已。

那请问一下,"ping &" 和 "ping"在表现上又什么区别呢?在脚本中,"ping &"会不会运行到"exit 0"这一步呢,如果可以的话,后台的这个"ping"命令会不会因为脚本退出而被结束掉呢?

不会的,加了&直接到后台去了,
------解决思路----------------------
引用:
它也不会因为parent脚本进程结束而被终结,而且这个时候,它获得了跟之前的parent进程同样的地位!


不是和parent进程同样的地位,而是一跃成为“进二代”,它的新的父进程是所有进程的老祖宗,不管它原来的父进程是谁。

下面的解释引自关于“parent process”的wikipedia文章(http://en.wikipedia.org/wiki/Parent_process):

Orphan processes
Main article: Orphan process

Orphan processes is kind of the opposite situation of zombie processes, since it refers to the case where a parent process terminates before its child processes, in which case these children are said to become "orphaned".

Unlike the asynchronous child to parent notification that happens when a child process terminates (via the SIGCHLD signal), child processes are not notified immediately when their parent finishes. Instead, the system simply redefines the "parent-pid" field in the child process's data to be the process that is the "ancestor" of every other process in the system, whose pid generally has the value 1 (one), and whose name is traditionally "init". It is thus said that "init 'adopts' every orphan process on the system".

A somewhat common assumption by programmers new to UNIX is that the child processes of a terminating process will be adopted this process's immediate parent process (hence those child processes' "grandparent"). Such assumption is incorrect—unless, of course, that "grandparent" is init itself.