<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I preface my comments with te fact that I am not a web/cgi programmer.
So what I describe may not translate well to that domain.<br>
<br>
If you are talking testing, you _really_ want to come up with a way to
use Perl's powerful testing support.<br>
<br>
In this case, as I see it, you are trying to achieve some kind of
coverage testing.<br>
<br>
And furthermore, you want a way to force fork() to fail with $!
populated with something that matches qr(No more process);<br>
<br>
I had a similiar issue with some coverage testing I did recently. You
can read about some of my issues on perlmonks, but the most relevant is
<a href="http://www.perlmonks.org/index.pl?node_id=377635">here</a>.<br>
<br>
One solution to writing tests for fork() failure is for you to override
the implementation of the builtin fork() with one that fails
appropriately.<br>
<br>
&lt;in ./t/forkfail.t&gt;<br>
#!/usr/bin/perl -w<br>
<br>
use strict;<br>
<br>
use Test::More qw(no_plan);<br>
<font size="2">
<pre><tt class="code">BEGIN {
    *CORE::GLOBAL::fork = sub (*\$$;$) { $! = &lt;whatever the appropriate errno is - read your systems errno.h&gt;;
                                        return undef };
}
</tt></pre>
</font>&lt;code that calls fork() and uses is() etc&gt;<br>
<br>
That solves the "1) How on earth can i test the <i
 class="moz-txt-slash"><span class="moz-txt-tag">/</span>No more process<span
 class="moz-txt-tag">/</span></i> line?" requirement - but maybe not in
the way your expecting/needing. But _if_, in production, the case
occurs, you know the right thing will happen cause you wrote a test
case to check it. You just cant (shouldnt?) do it at will in production.<br>
<br>
A note - the redefinition of functions in the *CORE::GLOBAL namespace
_MUST_ occur in a begin block - the reason is given <a
 href="http://www.perlmonks.org/index.pl?node_id=378264">here</a> - but
basically, the definition can only be overridden at compile time - this
<big><font size="2"><big>is because builtins aren't looked up every
time they are called - once compiled their function pointer (for want
of a better phrase) is immutable.<br>
<br>
BTW, my conclusions about coverage testing using Devel::Cover are
documented <a href="http://www.perlmonks.org/index.pl?node_id=378586">here</a><br>
</big></font></big><br>
<br>
<br>
<pre class="moz-signature" cols="72">-- 
Leif Eriksen
Snr Developer
HPA Pty Ltd

ph +61 3 9217 5545
</pre>
</body>
</html>