I am working on a shell right now and I have a question about processes and pids.
My shell is supposed to fork and execute a new program and then print out the name of the file and the process id.
if(*t == '&')
{
kidpid = fork();
if (kidpid == -1)
{
perror("Cannot Fork");
exit(1);
}
if (kidpid == 0)
{
//we know we are in the child
execvp(newargv[0], newargv);
pid = getpid();
printf("[" + pid + "]");
My question is regarding which pid is it going to print with this code. Does the execvp change the pid or is it going to be 0 each time since it is only executing this block of code if(kidpid == 0)?

New Topic/Question
Reply



MultiQuote




|