process and fork()

Process is a program in execution. Process execution must progress in sequential fashion. A process includes program counter, stack, and data section. In UNIX, a process is created by fork() system call. Below is the main fork() program based on C language.

int main()
  pid_t pid = fork();

  if (pid < 0)
		/*error occured*/
		fprintf(stderr,"error forking childn");
  else if (pid == 0)
		/*child process*/
		/* put your application here*/
		/*parent process*/
		int status;
		/*wait for child process to complete*/
		/*when child process has been completed, */
		/*it will return status 0 */

You may download a sample application to count fibonacci sequence that uses fork() system call,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.