I actually osted the code Ihad changed a little to see if it could work but left in the middle I am sorry for that and also for maiking the code so hard to read with stupid applicatipn of tags.

The code I compiled is :
Code:
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>

childprocess(int pid, int pnum);
main () {
	int pid, pid0, pid1, status, FD, tochild[2], toparent[2];
	FD = creat("new file.txt", S_IRWXU);
	if((pid = fork()) < 0) {
		printf("Could not fork process");
	} else {
		if(pid !=0)
			printf("\nProcess forked");
	}
	
	if(pid == 0) childprocess(pid,1);
	//if(pid != 0) {
		pid = wait(&status);
		printf("\nProcess (id %d ) exited ", pid);
		
	//}
	
	if((pid = fork()) < 0) {
		printf("Could not fork second process");
	}else{
		if(pid !=0)
			printf("\nSecond process forked");
	}	
	if(pid == 0) childprocess(pid,2);
	
//	if(pid != 0) {
		pid = wait(&status);
		printf("\nProcess (id %d ) exited " , pid);
//	} 
	close(FD);
	exit(0);
}

childprocess(int pid, int pnum) {
	float i = 0;
	int index = 0;
	for(index = 0; index < 900; index++) {
	}
	//printf("\nPID %d matches index : %d", pid, pnum); 
	exit(0);
}

Last edited by shabbir; 20Sep2007 at 14:57.. Reason: Code block