Our highest priority is to satisfy the customer through early and continuous delivery of valuable and working software.

Friday, December 21, 2007

Perl - fork() example

Here is a small example which demonstrate fork() implementation in PERL.


while(1)
{
my @children;

defined (my $pid = fork) or die "Cannot fork: $!\n";

if ($pid)
{
# Parent Process...

push(@children, $pid);
wait();
my $ret = $?;

if ($ret)
{
warn("Abnormal child exit: $!\n");
$daemon = undef;
last;
}
}
else
{
# Child Process...
exit(0);
}

while (scalar(@children))
{
wait();
my $ret = $?;
shift(@children);

if ($ret)
{
warn("Abnormal child exit: $!\n");
$daemon = undef;
}
}

}

continue
{
last unless $daemon;
sleep(10);
}

Ajax cache problem in IE

By default IE will cache all Ajax requests. If you make a same Ajax request again without clearing cache, every time you will get same data, instead of fresh data.

So, what's the solution?

Solution: Use either the date and time or a random number in the query string to force IE to reload the relevant document.

Example:
var QueryString = "request_id=x";
var DatetimeQueryString = “&datetime=”+new Date().getTime();
var url = “request_url.php?”+QueryString+DatetimeQueryString;
httpRequest.open(”GET”, url, true);
httpRequest.onreadystatechange = update;
httpRequest.send(null);