See exec:
If there is more than one argument in LIST, this calls execvp(3) with the arguments in LIST. If there is only one element in LIST, the argument is checked for shell metacharacters, and if there are any, the entire argument is passed to the system's command shell for parsing (this is /bin/sh -c on Unix platforms, but varies on other platforms).
What you get is your child PID, but the command is run through an intermediate shell, which then executes another shell.
You will need to either implement all the redirection yourself and use the list form of exec or write the command(s) to a shell script and exec that shell script. Some shells also can take a list of commands or a pipeline on their commandline, so maybe directly using the list form works too:
exec "/bin/sh", "/path/process.sh > /pathlogs/mylog.log";
In reply to Re: fork, exec and pid
by Corion
in thread fork, exec and pid
by luxAeterna
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |