Q: fork() & exec() question

Q: fork() & exec() question

Post by Andrey Simonenk » Wed, 12 May 1999 04:00:00



When I want to run new program(PROG) I should run fork() and run exec()
in child.

Parent before fork() can do a lot of checks for PROG (stat(), etc), but
exec() in child can be failed (no memory, etc).

In my propgram parent should know if call exec() in child was
successfull.

How can I do it ?

ps: please answer me also on my e-mail (a lot of messages in news groups
lost by my news server).

 
 
 

Q: fork() & exec() question

Post by Stefan Seefel » Wed, 12 May 1999 04:00:00



> When I want to run new program(PROG) I should run fork() and run exec()
> in child.

> Parent before fork() can do a lot of checks for PROG (stat(), etc), but
> exec() in child can be failed (no memory, etc).

> In my propgram parent should know if call exec() in child was
> successfull.

if you can't execute you program, simply terminate the child with exit(-1).
The parent should set a signal handler for sigchild so it can call wait()
(which avoids zombies by the way) to get the child's status.

Stefan
_______________________________________________________              

Stefan Seefeld
Departement de Physique
Universite de Montreal

_______________________________________________________

      ...ich hab' noch einen Koffer in Berlin...

 
 
 

1. Efficiency: fork() w/ shared libraries vs. fork()/exec()

I want to create a multiprocess application where each process has
a specialized and distinct function.

I can either fork()/exec() separate programs for each process
or link of the separate programs into a single dynamically linked image
and fork() multiple instances of it.

Question: which approach is the more efficient (under SunOS 4.1.x and 5.x)?

-Paul O'Keefe

2. RH6.0 jensen install

3. Fork & Exec inside Kernel

4. HP Lx/Pro NetRaid getting zapped

5. exec & fork in a system call

6. problems w/ cron on SCO

7. fork & exec

8. 80SL?

9. exec & fork in a system call

10. General Fork()/Exec()/System() Call Question

11. fork/exec question

12. Question on fork(), exec(), kill()

13. fork-exec-socket questions