Child Killing Parent

Hi all,

I am writing a script which calls other third party scripts that perform numerous actions. I have no control over these scripts.

My problem is, one of these scripts seems to execute and do what it is meant to do, but my calling / parent script always exits at that point. I need to figure out a way to call these child scripts, and for them to NEVER touch the parent. I have no idea why it is doing this, but hoping theres a simple way to stop it.

Here is what happens in my main parent script that simply calls other scripts.

Call Script 1
Call Script 2
Call Script 3
EXITS HERE
Script 4 never runs
Script 5 never runs

Whats in script3?
If you have a exec <something else e.g. menu...>
with a badly placed exit (or one too much..)
you can end up having parent script exit also, and so 4 and following are to never run...

I don't follow that. If my script, say pid 1223, invokes script B, a child process is created for script B, let's say it is pid 1337. Now script B can what it wants to pid 1337, but pid 1223 should stay intact.

One thing that script B might do is to obtain the pid of its parent and then explicitly kill that pid. To protect against that, we could do:
( scriptB )
The parentheses create a subshell and the subshell is now the parent of scriptB. We hope that scriptB will ignore its grandparent.

In the worst case,
echo /path/to/scriptB | at now
would totally disconnect scriptB, but now it's hard to wait for scriptB to finish.

Thanks for the replies.

The problem is, these scripts are not under my control at all. I can only think from the point of view of the parent, I need to run these scripts, and they should never be allowed kill the parent. Is this possible do you think from the parents point of view?

Thanks Perderabo for noting my nonsense, I was disturbed friday by phonecalls and people in my office when trying to post and got mixed up...the exec I was thinking about was on calling script 3, not inside...(silly because in present case there is no mention of exits...)
Anyway you are right here it looks more the script found its parent and explicitly killed it like a bugged ps -ef to get all process I launched to kill and in the lot there is my unfortunate parent...

Difficult because same UID...
But Perderabo gave you the workaround (a new subshell who becomes now the parent...).