954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Using fork() help.

I pretty much got my assignment working except for one part, I need to reverse the output if the user enters "-r" in the command line. Can anyone help me with this?

EDIT: By reverse I mean list the last child first down to the original process.

int j = strcmp( argv[2] , "-r" );
if ( j == 0 ){
	 printf("if statement entered\n");
   	 for( c = 0; c < depth; c++ ){
	
		if((fork())== 0)
   	       printf( "Process %d reporting; parent is %d\n", getpid(), getppid() );
  	     else{
		   wait();
		   exit(0);
		}
  	  }		

    }
DeadJustice
Light Poster
44 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

Please disregard. I have solved this issue.

DeadJustice
Light Poster
44 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You