Specifically, I want to view the /proc/PID/io file for a child process created by fork(). I can only think to try to access it within the parent process, but it is always inaccessible.
pid_t pid = fork();
if (pid < 0) // failed
{
return;
}
else if (pid == 0) // child process
{
char* args[] = { "cat", "test.txt" };
execv(args[0], args);
}
else // parent process
{
wait(NULL);
}
The file is accessible before the call to wait, but it of course doesn't contain any nonzero values since the child hasn't finished yet. The file is inaccessible after the call to wait, because the child has terminated. So, how would I go about this?
Admittedly, this is for a project, but we have not covered anything beyond basic forking. Any help is appreciated.