bproc question

Jag agrajag@linuxpower.org
Wed, 7 Mar 2001 19:46:58 -0800


--Z0mFw3+mXTC5ycVe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, 07 Mar 2001, Dan Smith wrote:

>=20
> I am trying to write a simple program that uses bproc_execmove just to see
> how it works.  The documentation says very little.  Can someone give me a
> hand?
>=20
> Here is what I have:
>=20
> #include <stdio.h>
> #include <sys/bproc.h>
>=20
> int node, stat, num;
>=20
> main(int argc, char *argv[])=20
> {
>=20
>   num =3D bproc_numnodes();
>   node =3D (int)argv[1];
>   printf("Number of nodes: %d\n", num);
>   printf("Command: %s\n", argv[2]);
>   stat =3D bproc_execmove(node, argv[2], 0, 0);
>   printf("Status of bproc_execmove =3D %d\n", stat);
>=20
> }
>=20
> I am compiling with -lbproc.  It compiles without complaint.  When I run =
it
> and give it a node and a binary to execute it seems to stop at the
> bproc_execmove.  In this case the binary is called "hi" and it just prints
> "Hello, World!"
>=20
> $ ./mover 0 ./hi
> Number of nodes: 10
> Command: ./hi
>=20
> It doesn't get to the last print statement which tells me
> whether bproc_execmove even worked.

This is the expected results.  bproc_execmove() works much like
exec() in that it will only return if it fails.  If it succeeds, the
current process is replaced by the process you are execing.  Thus,
this program is no longer running so your last printf can never be
executed.
bproc_execmove is actually very similar to bproc_rexec.  The main
difference is that with rexec, it tries to run a program located on the
remote node.  With execmove, it execs the process locally, and
immediately moves it to the remote node.

If you want to keep your spawning process running, I'd suggest you
either fork() locally, then call bproc_execmove(), or if you want
rexec() functionality, use rfork() then a standard exec() call.


Jag

--Z0mFw3+mXTC5ycVe
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6pwCy+pq97aGGtXARAoeKAJ9hS+EB1m4P8kUHbw37qqhuDZX7TQCgtwt2
x7LAfgp0mSQkhFa+hrWJpog=
=lo0T
-----END PGP SIGNATURE-----

--Z0mFw3+mXTC5ycVe--