fork a new process in perl

I was doing something today and found that I require to fork a new process in perl. Now I had never done this earlier, so I did not know how to do this.

First some background :

I was doing some program very similar to http server, where the script accepts some input through a socket and then processes the same. In doing so I was seeing that the script was taking some time in processing the input and thus was not processing the second request until the first one was completed. Simple solution, fork the process.

[cc lang=”perl”]

$pid=fork();

if (! $fork)

{

do the child processing

exit

}

else

{

do the parent processing

exit

}

Enhanced by Zemanta

Inotify Example: Introduction to Inotify with a C Program Example


Inotify Example: Introduction to Inotify with a C Program Example:

inotify utility is an effective tool to monitor and notify filesystem changes. You can specify a list of files and directories that needs to be monitored by inotify. This library is used by various other programs. For example, CPAN module Linux::Inotify is developed based on this library.
iNotify Execution Flow

On a high-level, you do the following with inotify utility.

\"Reblog