Newsgroups: comp.parallel.pvm
From: john@elroy.jpl.nasa.gov (John Wright)
Subject: Re: How to halt master pvmd within program
Organization: Image Analysis Systems Group, JPL
Date: 2 Oct 1995 16:29:31 GMT
Message-ID: <44p41b$6em@elroy.jpl.nasa.gov>

In article <44ee6p$3ed@ns.mcs.kent.edu>,
Stephen Scott <sscott@nimitz.mcs.kent.edu> wrote:
>I would like to be able to halt all pvmd processes, effectively 
>stopping pvm, from within a C program.  Using pvm_delhosts()
>I am able to halt all pvmd`s except for the "master" pvmd.
>When attempting to halt the "master" pvmd using pvm_delhosts() -
>I am returned the error code "PvmBadParam" (-2) - I assume because
>one should not try to remove the "master" pvmd.
>
>Any suggested solutions?
>
>stephen.

Others have suggested pvm_halt which works fine except it will
kill hte program calling it.  Apparently the call to pvm_halt
(and all other pvm calls) enrolls the calling program in pvm,
then the halt kills all enrolled processes.

To avoid the calling process being killed I have used the
following function (which is not guaranteed but I think it works):

int pvm_halt(void)
{
        char    *tname, *aname, command[1024];

        tname = getenv("PVM_ROOT");
        if(!tname) {
                fprintf(stderr," PVM Root Directory not set -- check
.cshrc\n");                return(PvmCantStart);
        }
        aname = getenv("PVM_ARCH");
        if(!aname) {
                fprintf(stderr," PVM Architecture Environment not set
-- check .cshrc\n");
                return(PvmCantStart);
        }

        fprintf(stderr,"Shutting down PVM net.\n");
        sprintf(command,"echo halt | %s/lib/%s/pvm >/dev/null", tname,
aname);
        system(command);
        return(NET_OFFLINE);
}

Hope this helps.

John


-- 
john@tone.jpl.nasa.gov
---Signature under construction---
(I quail at the impossibility of capturing the 
essence of myself in four lines in an ASCII file)

