Hello,
I am observing a behavior where when the parent spawns a child and when
the child terminates abruptly (for example with exit() before
MPI_Finalize() ), the parent also terminates even after both the child
and parent have explicitly called a MPI_disconnect. This turns out to be
a disadvantage. A sample program is as follows:
Parent:
int main (int argc, char *argv[])
{
MPI_Init(&argc, &argv);
MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
MPI_Comm child_comm;
MPI_Comm_spawn("./child", MPI_ARGV_NULL, 1, MPI_INFO_NULL, 0,
MPI_COMM_SELF, &child_comm, MPI_ERRCODES_IGNORE);
printf("spawned a child\n");
MPI_Comm_disconnect(&child_comm);
printf("Disconnected from the child\n");
sleep(5000);
MPI_Finalize();
return 0;
}
Child:
int main (int argc, char *argv[])
{
MPI_Init(&argc, &argv);
MPI_Comm parent, parent1;
MPI_Comm_get_parent(&parent);
MPI_Comm_disconnect(&parent);
if(parent == MPI_COMM_NULL)
printf("Child: Disconnected from the parent, Exiting\n\n");
MPI_Comm_get_parent(&parent1);
if(parent1 != MPI_COMM_NULL)
printf("Child: yes, i got my parent again\n");
exit(1); //abrupt end
MPI_Finalize();
return 0;
}
In the above simple example, the second printf will not be displayed
clearly indicating that the child is really disconnected from the
parent. However, at exit() of the child, the parent terminates too.
Perhaps there is a way to avoid this kind of auto cleanup?
Thanks,
Suraj Prabhakaran