Monday, February 05, 2007

system() vs fork()-exec()

system() vs fork()-exec()

system() :
- Uses a shell and the shell does the actual execution
- Dependent on the currently used shell.
- There will be two processes created as a result.
- Not as efficient.
- Easier to use?

fork()-exec() :
- No shell used - only one process will be created
- A little bit more complex to use.

If you want to run some commands with pipe operations (e.g. |, >>, <) then using system() is probably much easier.

No comments: