tags:

views:

70

answers:

1

I'm having a problem using system("command") call in C on an embedded system in linux. The call to the app works fine on the command line but when called in a compiled cgi script using the system command it is painfully slow. Any help appreciated?

+2  A: 

Using system() invokes a shell to process the arguments you provide. In my experience, it's rarely useful to have the shell involved when the need is simply to run an external command. The shell adds overhead, and that may be what is slowing you down.

If what you're doing doesn't really require the shell, then instead of system() try using fork() to create a child process, followed by exec() to run the executable you need.

Mox
It'd have to be a painfully tiny system for the cost of starting a shell to make something 'painfully' slow...
Spudd86