Reputation: 983
I'm creating a nodejs program that need to use some unix command.
I have two choices either execute them using exec('command ...')
which just execute the command with the given arguments.
Or through IPC communication.
What are the benefits of using IPC instead of exec ?
Upvotes: 0
Views: 497
Reputation: 60107
It depends on what that program is.
Exec
ing incurs a cost associated with having to fork a child and load it (the actual system-level exec).
If you're going to be using that unix program a lot, like if you're writing a server, using IPC could allow you to pay that price only once but it's dependent on that unix program's ability to be run as a server in your IPC setup.
Upvotes: 1