Mail Archives: djgpp/1996/01/17/04:11:41
Orlando Andico <oandico AT gollum DOT eee DOT upd DOT edu DOT ph> wrote:
>Does anyone know why gcc on multitasking systems doesn't have spawn...()?
>(sorry if this isn't related directly to DJGPP...) I use spawn with DJGPP
>all the time... now I want to do the same thing under Linux. But there's
>no spawn.
The ANSI standard (i think) defines a library call system() that is supposed
to allow you a way to OS-independantly run a program such that you are
guaranteed that the program will have finished execution before the call
to system() returns.
Perhaps this is what you are looking for. Any unix worth its salt has
ANSI compliant c libs by now (which of course precludes sunos 4. >;-)
>This seems to work, but the problem is, my program is inherently
>single-threaded and needs something from the _thing_that_is_spawned_.
>But due to the fork(), I can't know if the _thing_to_be_spawned_ has
>done its thing yet... (unlike spawn which returns when the _thing..._
>has done its potty). Any ideas?
Look at the man pages for wait() and waitpid(). Waitpid() is pretty
good when you *know* the pid of the child (such as after a fork())
and its just what youre looking for. wait() is more useful when you
dont know who your child is, but you know you have one. More informative
versions of wait*() exist, but i wouldnt count on them being very
portable.
However, for you, i think what you want is the system() call which
handles all the details for you and gives you reasonble semantics.
jfn
- Raw text -