[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: spawn




marc <m_schellens@hotmail.com> writes:

> I want to spawn under UNIX one program many times (multiprocessor
> machine). So I could sent it into the background using the UNIT keyword,
> but how can I determine when the program finishes?
> I run some basic tests and it seems that IDL leaves the unit open.
> Is there a way or have I (ab)use the filesystem for this (via
> lockfiles)?

A clarification is in order.  SPAWN with the UNIT keyword does *not*
run the process in the background.  The unit stays open because IDL
attaches the output of the process to the unit, and IDL is waiting for
you to read the output.

You can run the process in the background by adding '&' like you
normally would.  Then be sure that you redirect the output and CLOSE
the unit.

To find out whether a background process is finished is difficult.
Usually it's just easiest to write a flag to a temporary file when the
job is done, and have IDL periodically monitor that file for changes.
One can probably do it with the unix system call waitpid(), but you
that would require compiling a DLM, not for the faint of heart.

Good luck,
Craig

-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------