I am a beginner for system programming, I'd like to use fork-exec
programming to perform a "C-code compilation" and see if any
compilation errors within ......
For now, I had create a process to perform the system call *exec()*. I
could make the main process to wait the created one, like this...
pid_t pid = fork();
printf("This message means it failed to create a process\n");
wait( (int*)0 ); // wait for created process has been finished.
/* Do something herefor stdout/stderr generated by child process*/
execl("/bin/ls", "ls", "-la", ">", "log.txt", (char*)0);
printf("This message means system call *execl()* failed\n");
For my observation, *execl()* pass the command ">" to "ls" as a
parameter. The program "ls" treat ">" as a target file name or
So I think ">" is a shell command(or operator something), right?
then how should I redirect a stdout/stderr to a buffer(or a file)?