Bernd Antweiler wrote:
> My situation: I have written a program in C under Linux which should
> control another commercial application. In detail: My program starts a
> finite-element-solver (MARC) with system(...). It should wait until
> MARC has written its solution file, read this file, work with the
> data, etc. The problem: MARC takes itself to the background, system
> (...) returns and my programm wants to continue with working. Error,
> no file available naturally (MARC needs in this case 30 secs.). What I
> know: 1. System is a procedure with fork(...), wait (...) and so to
> create a sub process and there are certain parameters to modify sub
> processing. 2. I could do a workaround with reading the status of the
> solution file, but because of the critical time conditions of the
> approximation algorithm in my program I don't want this.
>
> What I want to know: Are there parameters of wait, waitpid, etc. to
> force my program waiting for the solution file (MARC's finishing)? Are
> there other possibilities on system level available to implement in C?
If MARC backgrounds itself, then this implies that it is performing
its own fork(), after which the parent terminates. Consequently, it
will be inherited by init, and the SIGCHLD announcing its termination
will be sent to init.
Unless you can force MARC to remain in the foreground, then I suspect
that the only solution will be to scan /proc to find out its pid, and
then stat() the /proc/<pid> directory periodically to discover when it
terminates.
--
Glynn Clements <[EMAIL PROTECTED]>