pid_t pid;
pid=fork();
if (pid == 0)
{
//child process.
execl("/opt/bin/version.out", "version.out > /tmp/version",0);
_exit(0);
}
else
{
// this is parent, wait for child to finish.
waitpid(pid, NULL, 0);
verDir("/tmp/version");
}
With the above c++ code, I am trying to create a child process, execute command /opt/bin/version.out and redirect the output to /tmp/version, but it doesn't create /tmp/version at all, any error with above syntax? is execl() and waitpid() syntax correct? Thanks.