bproc question In-reply-to: Your message of "Wed, 07 Mar 2001

Jag agrajag@linuxpower.org
Wed, 7 Mar 2001 20:32:54 -0800


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

On Wed, 07 Mar 2001, Dan Smith wrote:

>=20
> Thanks!  This explains a lot, actually.  I have another question.  Is it
> possible to have a program that has been moved to a slave node (via
> bproc_execmove(), for instance) send it's output to a file on the slave
> node's local disk using a simple redirect?  I want to be able to start a
> program on different nodes and have them each redirect there output into
> files on their own local disks.  Better yet, can I also feed them input w=
ith
> redirects from files that are local to each slave?  Am I making any sense=
? =20
> Thanks for any advice you can give.

I think you're making sense.  Sounds like you're wanting to do something
similar to the shell redirects that are normally done with < and >

I've actually written something to do this, however I did it in python
(using pybproc to get the bproc functionality), but it should be
portable to C without to much trouble.  The basic flow is bproc_rfork(),
on remote node redirect stdin, stdout, and stderr, then exec() the
program on the remote node.  When I did mine, I assumed the binary and
input/output files would all be on an nfs share such as /home.

Here's a quick attempt to put it into C, but I haven't even run it
through a compiler yet, so good luck :)

pid =3D bproc_rfork(node);
if (!pid) {
  infile =3D ("/home/foo/input", "r");
  outfile =3D ("/home/foo/output", "a");
  dup2(infile, stdin);
  dup2(outfile, stdout);
  dup2(outfile, stderr);
  exec("/home/foo/myprog", {"myprog", "--option"});
  /* should never get here */
} else{
  /* whatever you want to do on the master node */
}


Hope this helps,


Jag

--Ah9ph+G2cWRpKogL
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

iD8DBQE6pwt2+pq97aGGtXARAvCMAJ93/xsd88zjIGYRcVUdtDlSqdsWiQCeOlSr
XufemEPvXpjnyWxXtlvtRHM=
=QivA
-----END PGP SIGNATURE-----

--Ah9ph+G2cWRpKogL--