Processes

This is a discussion on Processes within the C Programming forums, part of the General Programming Boards category; 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 ...

  1. #1
    wise_ron wise_ron's Avatar
    Join Date
    May 2006
    Posts
    75

    Lightbulb Processes

    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:
    Code:
    #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;
    }
    Thanks

    Wise_ron
    Attached Files Attached Files

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Quote Originally Posted by wise_ron
    I am stuck in this part where i need to do the Printing System Process Chart using “ps -al”
    Code:
      return_value = system ("ls -all /");
    Um, did you mean ps -all instead of ls -all???

  3. #3
    wise_ron wise_ron's Avatar
    Join Date
    May 2006
    Posts
    75

    Um, did you mean ps -all instead of ls -all???

    Code:
    i meant ps -all
    I still dont get the output that i want. Can someone explain how the ps works and give me a basic example.

    Thanks

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    man ps

    They write those things for a reason you know.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 34
    Last Post: 05-27-2009, 12:26 PM
  2. Task Manager: Applications vs Processes
    By Shwick in forum Windows Programming
    Replies: 3
    Last Post: 08-14-2008, 06:47 AM
  3. Processes not dying
    By Elkvis in forum Linux Programming
    Replies: 12
    Last Post: 04-23-2008, 08:59 AM
  4. binary tree of processes
    By gregulator in forum C Programming
    Replies: 1
    Last Post: 02-27-2005, 11:59 PM
  5. Unix processes
    By J-Dogg in forum Linux Programming
    Replies: 1
    Last Post: 03-24-2003, 04:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21