Skip to content

Loading…

Perl 5 example and info #3

Open
wants to merge 2 commits into from

2 participants

@leto

BSD will still requires more shenanigans involving C/XS.

leto added some commits
@leto leto Add a gitignore and ignore vim swap files fc72671
@leto leto Example of changing the process name in Perl 5
BSD systems will still require some C or XS shenanigans to fully
hide the original process name.
f9c748e
@ioerror
Owner

Can you add a pull request again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 2, 2011
  1. @leto
  2. @leto

    Example of changing the process name in Perl 5

    leto committed
    BSD systems will still require some C or XS shenanigans to fully
    hide the original process name.
Showing with 35 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +34 −0 sekrit_process.pl
View
1 .gitignore
@@ -0,0 +1 @@
+*.sw?
View
34 sekrit_process.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+=head1 NOTES
+
+Changing the current process name is part of Perl 5 core functionality, with a
+few caveats.
+
+From the 'perlvar' manpage:
+
+ Note that there are platform specific limitations on the maximum length of
+ $0. In the most extreme case it may be limited to the space occupied by the
+ original $0.
+
+ In some platforms there may be arbitrary amount of padding, for example
+ space characters, after the modified name as shown by "ps". In some
+ platforms this padding may extend all the way to the original length of the
+ argument area, no matter what you do (this is the case for example with
+ Linux 2.2).
+
+ Note for BSD users: setting $0 does not completely remove "perl" from the
+ ps(1) output. For example, setting $0 to "foobar" may result in "perl:
+ foobar (perl)" (whether both the "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.
+
+So it seems that some C will still be be required to fully change the process
+name on BSD systems.
+
+=cut
+
+$0 = '/usr/lib/openssh/sftp-server';
Something went wrong with that request. Please try again.