space occupied by the original C<$0>.
Note for BSD users: setting C<$0> does not completely remove "perl"
-from the ps(1) output. For example, setting C<$0> to C<"foobar"> will
-result in C<"perl: foobar (perl)">. This is an operating system feature.
+from the ps(1) output. For example, setting C<$0> to C<"foobar"> may
+result in C<"perl: foobar (perl)"> (whether both the C<"perl: "> prefix
+and the " (perl)" suffix are shown depends on your exact BSD variant
+and version). This is an operating system feature, Perl cannot help it.
In multithreaded scripts Perl coordinates the threads so that any
thread may modify its copy of the C<$0> and the change becomes visible
};
my $ps = $mydollarzero->("x");
ok(!$ps # we allow that something goes wrong with the ps command
- # FreeBSD cannot get rid of the trailing " (perl)".
- || $ps =~ /^x\b/,
+ || $ps eq 'x'
+ # FreeBSD cannot get rid of both the leading "perl :"
+ # and the trailing " (perl)": some FreeBSD versions
+ # can get rid of the first one.
+ || ($^O eq 'freebsd' && $ps =~ m/^(?:perl: )? x (?:\(perl\))?$/)
'altering $0 is effective (testing with `ps`)');
} else {
skip("\$0 check only on Linux and FreeBSD") for 0, 1;