Reputation: 16724
I need to run a command,but that don't lock my application until exit of it,like do system()
function.
Upvotes: 0
Views: 245
Reputation: 753585
pid_t pid;
if ((pid = fork()) < 0)
...fork failed...
else if (pid == 0)
{
...create command line in array of char pointers argv...
...sort out I/O -- redirect stdin from /dev/null?...
execvp(argv[0], argv);
...report exec failed on stderr...
_exit(126);
}
...parent process...gets on with life...
Upvotes: 2
Reputation: 798546
Use fork()
to create a new process, and exec*()
to replace it with a new application.
Upvotes: 7