I am running a script from one machine on another machine using ssh.
ssh <host> a.pl
Now, a.pl starts several other instances of a.pl using the 'system' method and executing each of them in the background. I have this integrated with LDAP and when one of the instances dies, the main a.pl script comes to know about this as it continuously keeps on monitoring them. Consequently, on finding that one of the instance has died, the main script dies too and the remaining instances are then owned by init (1).
I would expect ssh to exit when this main script dies. But, somehow it seems that ssh keeps on waiting on all the processes that were launched. ssh exits when I kill the remaining instances.
Is this the expected behavior? If yes, why is this so?