From: Alexandre Ferrieux on
On Jul 16, 6:20 am, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote:
> I think I forgot to say, this is Windows.

Oh ! (you said it 'forked', so I had a bit of hope... too bad)


> So the child process here is a package called comsol, and the
> grandchild is a package called matlab.
>
> We have confirmed that, when comsol is already terminated, matlab is
> still going on. And only when matlab is done, the file "file01.txt"
> will be created and saved.

Ok I googled a bit and found the idiom you are using at

http://www.comsol.com/support/knowledgebase/980/

while I have no idea of the details making you use comsol vs.
comsolbatch, it looks like the former is more oriented towards
interactive display (but the window-suppressing flags are puzzling in
that case). Is it possible for you to use comsolbatch instead ?

If not, I'm afraid you're stuck with digging through the comsol.exe
documentation and/or support to convince the sucker to _wait_ for its
child. Given the documented "dosomething, exit" argument to the matlab
child, it would be normal for comsol.exe to have a /waitforchild flag.
But in Windows you never know :/

-Alex

PS: if you really can't do otherwise, try adding to the end of your
matlab script (before exit) something that creates yet another
signalling file, after closing the result file. This way, by
monitoring the second one you're sure that the first is closed.
From: Alexandre Ferrieux on
On Jul 16, 6:20 am, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote:
>
> exec $comsol_cmd matlab -ml /nodesktop -ml /nosplash -mlr
> "antenna_COMSOL_01, exit"

I've been looking at the matlab docs a bit, and I'm puzzled by the
fact that the matlab process lingers despite the 'exit'. Now I see
that there's also 'quit', which accepts a few options like 'force'.
So, in case this non-dying process is somehow waiting for a
confirmation in an invisible window, try using 'quit force' instead of
'exit'.

Also, to analyze better what's going on, you could remove the /
nodesktop flag. Maybe some error in your matlab script goes back to
the interactive loop before 'exit' can be called; in that case you
might see it clearly with windows enabled (who knows)...

-Alex