Write a program to show the process of spawning a child process? - CGI Programming

Write a program to show the process of spawning a child process?



- A process can be created and it can create further more processes that execute the code independently.

- CGI program allows the creation of a program that spawns a child process to perform the task and the parent process control the actions on the browser.

- CGI program saves lots of time and effort to finish a task as the child processes runs in the background.

- The program is as follows that shows that in practical:

#!/usr/local/bin/perl
$| = 1;
print "Content-type: text/plain", "\n\n";
print "Creation of child process!", "\n";
if ($pid = fork)
{
print <This is the parent process and I am ending
End_of_Parent
} else {
close (STDOUT);
system ("/usr/bin/rm", "-fr", "/tmp/CGI_test", "/var/tmp/CGI");
exit(0);
}
exit(0);
Post your comment