It's pretty much a non-issue. The shell running that script will be killed off during the shutdown process. When you do a shutdown, all running processes will be sent a SIGINT signal to tell them that they should stop whatever they are doing, clean up and exit. About five seconds later, any process that hasn't obeyed will be summarily shot. That is, they are sent the SIGKILL signal, which they cannot trap or ignore. In this way, all processes are given a chance to do a nice clean termination. If they don't cooperate, the system kills them off.
In your case, you've got two processes running: your shell that's running the script, and its child process running sleep(1). They will both receive the SIGINT at about the same time. The sleep will wake up and exit. The shell will just immediately exit, before it even tries to look at the exit status of the sleep it spawned. So it won't have the opportunity to try to restart your program, if that's what you're worried about.
|