From: kagel AT quasar DOT bloomberg DOT com Date: Mon, 15 Jan 1996 08:54:14 -0500 To: oandico AT gollum DOT eee DOT upd DOT edu DOT ph Cc: djgpp AT delorie DOT com Reply-To: kagel AT quasar DOT bloomberg DOT com Date: Sat, 13 Jan 1996 13:28:06 -0800 (GMT) From: Orlando Andico 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. Apparently, the solution is to fork(), do nothing in the child (return value == 0) and execve() the _thing_to_be_spawned_ in the parent (overwriting momma). 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? Thanks, I think the UNIX/LINUX function you are looking for is 'system()' which forks, execs a shell and hands the shell its argument string as a command. System() blocks until the command completes unless the command backgrounds itself (either internally or because you have included and ampersand (&) at the end of the command). To simulate this by hand, fork then, in the child, exec the program you need while in the parent call wait() which will wait for all child processes to exit before returning. If you want to get some work done while the program churns you can call wait afterwards or set a signal handler to trap SIGCHLD (or SIGCLD I don't know which define LINUX supports, maybe both), then call wait() in the signal handler to avoid zombying (or DEFUNCTing) your child and set a flag you can test later in your main-line code. -- Art S. Kagel, kagel AT quasar DOT bloomberg DOT com A proverb is no proverb to you 'till life has illustrated it. -- John Keats