Killing parent shells from subshells (KSH)

Hi all,

I have a shell script which calls other shell scripts, depending on the input.

Within a.sh, I have a command which calls b.sh (ie. ksh b.sh)

Normally, we use the exit function to terminate a shell. However, if I choose to call exit from b.sh, I will return to the parent shell who activated the shell (ie. a.sh), rather than to close the application completely.

Is there a command that I can use to close all parent shells from b.sh?

Thanks in advance.

Use 'exec b.sh' instead of 'ksh b.sh'

Thanks a lot!

Suppose that I want to allow the user to have a choice between:

  1. Terminating the shell completely
  2. Or closing the subshell and going back to the previous shell script that called it.

How can this be implemented? Is it through the use of using ksh b.sh instead of exec b.sh and then:

  1. have a case statement which calls exit from the subshell to go back to previous page.

  2. use some signal to kill the whole shell

Am I correct to say this? If so, what is the command to be used to implement the signals?

Thanks in advance.

If the parent shell script used "exec" to call your script then the parent script has gone when you shell runs.

This is because exec replaces the current program with a new one. The old program is no longer running.