in reply to using system and exec in same script using child
The if is executed in both the parent and the child, as made obvious by the "then" part being executed in the parent and the "else" part being executed in the child.
So why do you think the line that follows the if would only be executed in the parent?
exec replaces the program the process is executing with another and it never returns (except on error). So yes, using exec is appropriate since you don't want to continue executing the program int he child.
By the way, system is a combination of fork, exec and wait or waitpid. That might fail if the child launched by fork ends before the child launched by system. You might have to avoid using system to customize the use of wait
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using system and exec in same script using child
by cdarke (Prior) on Jan 11, 2010 at 10:59 UTC | |
by convenientstore (Pilgrim) on Jan 11, 2010 at 22:33 UTC | |
by BrowserUk (Patriarch) on Jan 11, 2010 at 23:49 UTC | |
by convenientstore (Pilgrim) on Jan 14, 2010 at 16:54 UTC | |
by convenientstore (Pilgrim) on Jan 14, 2010 at 17:12 UTC | |
by ikegami (Patriarch) on Jan 11, 2010 at 22:49 UTC |