Hi everyone first of all i want to thank.
fnoyan
http://www.advancedlinuxprogramming....04-threads.pdf
He mention this link and it has been helpful with what i have been working on. Our class is specially dealing with Processes which will be chapter 3 of this book. This the program i want to output that is attached.
I am stuck in this part where i need to do the Printing System Process Chart using “ps -al”
When it prints the ps -all it does not give me the same output. Why do you think is not printing the same output?
this is the code i have so far:
ThanksCode:#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main ()
{
pid_t child_pid;
int return_value; // return value to show the system process using "ps -all"
printf("Iam a process. \b\n");
printf ("My PID is %d and my parent's PID is %d \b\n", (int)getpid (),(int)getppid ());
// getpid(): returns the process ID of the current process.
// getppid(): returns the process ID of the parent of the current process
printf("Forking a child off \b\n");
child_pid = fork(); //creating the child
if (child_pid != 0)
{
printf("Child: I have been created!\b\n");
printf("I created a child and its PID is %d \b\n", (int) child_pid); // childs proccess ID (PID)
printf("Printing System Process chart using \"ps -al\" \b\n");
}
else
{
printf("this is the child process, with id %d\n",(int) getpid ()); // returning to step 3 in program II
}
return_value = system ("ls -all /");
//return return_value;
return 0;
}
Wise_ron