Change 19935 by [EMAIL PROTECTED] on 2003/07/02 20:01:06
It would seem that in Linux 2.2 there is no way
we can do the right thing to make ps(1) see $0
our way. Also amend the $0 documentation a bit.
Affected files ...
... //depot/perl/pod/perlvar.pod#125 edit
... //depot/perl/t/op/magic.t#67 edit
Differences ...
==== //depot/perl/pod/perlvar.pod#125 (text) ====
Index: perl/pod/perlvar.pod
--- perl/pod/perlvar.pod#124~19925~ Wed Jul 2 01:40:36 2003
+++ perl/pod/perlvar.pod Wed Jul 2 13:01:06 2003
@@ -838,18 +838,22 @@
=item $0
-Contains the name of the program being executed. On some (read: not
-all) operating systems assigning to C<$0> modifies the argument area
-that the C<ps> program sees. On some platforms you may have to use
-special C<ps> options or a different C<ps> to see the changes.
-Modifying the $0 is more useful as a way of indicating thecurrent
-program state than it is for hiding the program you're running.
-(Mnemonic: same as B<sh> and B<ksh>.)
+Contains the name of the program being executed.
+
+On some (read: not all) operating systems assigning to C<$0> modifies
+the argument area that the C<ps> program sees. On some platforms you
+may have to use special C<ps> options or a different C<ps> to see the
+changes. Modifying the $0 is more useful as a way of indicating the
+current program state than it is for hiding the program you're
+running. (Mnemonic: same as B<sh> and B<ksh>.)
Note that there are platform specific limitations on the the maximum
length of C<$0>. In the most extreme case it may be limited to the
space occupied by the original C<$0>.
+In some platforms there may be arbitrary amount of padding, for
+example space characters, after the modified name as shown by C<ps>.
+
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"> may
result in C<"perl: foobar (perl)"> (whether both the C<"perl: "> prefix
@@ -858,7 +862,9 @@
In multithreaded scripts Perl coordinates the threads so that any
thread may modify its copy of the C<$0> and the change becomes visible
-to ps(1) (assuming the operating system plays along).
+to ps(1) (assuming the operating system plays along). Note that the
+the view of C<$0> the other threads have will not change since they
+have their own copies of it.
=item $[
==== //depot/perl/t/op/magic.t#67 (xtext) ====
Index: perl/t/op/magic.t
--- perl/t/op/magic.t#66~19927~ Wed Jul 2 01:48:00 2003
+++ perl/t/op/magic.t Wed Jul 2 13:01:06 2003
@@ -300,7 +300,13 @@
};
my $ps = $mydollarzero->("x");
ok(!$ps # we allow that something goes wrong with the ps command
- || $ps eq 'x'
+ # In Linux 2.4 we would get an exact match ($ps eq 'x') but
+ # in Linux 2.2 there seems to be something funny going on:
+ # it seems as if the original length of the argv[] would
+ # be stored in the proc struct and then used by ps(1),
+ # no matter what characters we use to pad the argv[].
+ # (And if we use \0:s, they are shown as spaces.) Sigh.
+ || $ps =~ /^x\s*$/
# FreeBSD cannot get rid of both the leading "perl :"
# and the trailing " (perl)": some FreeBSD versions
# can get rid of the first one.
End of Patch.