Newsgroups: comp.parallel.pvm
From: Matthieu Exbrayat <exbrayat@lisiflory.insa-lyon.fr>
Subject: Re: Using fork(2) in spawned task
Organization: C.I.S.M.  Universite de Lyon 1 / INSA de Lyon
Date: Thu, 15 May 1997 10:01:06 +0200
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <337AC2C1.41C67EA6@lisiflory.insa-lyon.fr>

Well, I did not find docs on pvmendtask(). So I tried it.
It makes the son independant from his father in the pvm way.
This means that if you did a pvm_kill in the son, you would stop the
father's pvm connection in the same time. So you do
a pvmendtask, which allows the son to restart a distinct pvm
connection with the following pvm_mytid().
If you did not put the pvmendtask, the son's pvm_mytid would return the
father's tid. And then, when you stop the son's pvm connection,
you also stop the father's one.
This code is an extract and supposes you launched
pvm_mytid() in the father process, just as in the following :

main()
{
int     father,son;

father=pvm_mytid();

if (fork())
        {
        printf("I am father\n");
        pvm_exit();
        }
else
        {
        pvmendtask();
        son=pvm_mytid();
        printf("I am the son\n");
        pvm_exit();
        }

Good luck in pvm-land ;-)

mr844345 wrote:
> 
> I am wondering can I use fork in a spawned child, since it stopped running
> with a return value "EOF". I don't know what it means.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Matthieu EXBRAYAT	   |						~
~ LISI - INSA Lyon	   | e-mail : exbrayat@lisiflory.insa-lyon.fr	~
~ Bat 401		   |						~
~ 20, av. A. Einstein	   | tel : (33) 72 43 84 67			~
~ 69621 Villeurbanne Cedex | 						~
~-----------------------------------------------------------------------~
~	url : http://www.insa-lyon.fr/People/LISI/matthieu		~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

