diff options
author | Paul Saab <ps@yahoo-inc.com> | 2000-08-01 08:41:39 -0700 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-08-02 01:27:44 +0000 |
commit | 4bc88a62f4d56d50d2cea2bb6c705aea33b892f4 (patch) | |
tree | 281eae336a7a863e88b21a577d5df975bdb22222 | |
parent | 00c29ff8bf429b0884d885b7604c1d33f673b0c3 (diff) | |
download | perl-4bc88a62f4d56d50d2cea2bb6c705aea33b892f4.tar.gz |
In new BSDs changes to argv[] do not show up in ps(1) output,
instead one must use setproctitle(). This was already addressed
by change #6457, but the below has a new variant for FreeBSD 4.0
or later, and the matter is also documented more.
Subject: [ID 20000801.007] setting $0 on FreeBSD 4.x does not get reflected in /bin/ps
Message-Id: <20000801154139.A53740@yahoo-inc.com>
p4raw-link: @6457 on //depot/perl: 0c9177abdae6e91f4dfdab2ef3cc817ec901e51eon //depot/metaconfig: efc5abcdbec468dfb20e18acbe3ab6c1cd9e92c3
p4raw-id: //depot/perl@6483
-rwxr-xr-x | Configure | 8 | ||||
-rw-r--r-- | config_h.SH | 6 | ||||
-rw-r--r-- | mg.c | 27 | ||||
-rw-r--r-- | perl.h | 4 | ||||
-rw-r--r-- | pod/perlvar.pod | 5 |
5 files changed, 46 insertions, 4 deletions
@@ -20,7 +20,7 @@ # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ # -# Generated on Tue Aug 1 20:27:06 EET DST 2000 [metaconfig 3.0 PL70] +# Generated on Wed Aug 2 03:07:08 EET DST 2000 [metaconfig 3.0 PL70] # (with additional metaconfig patches by perlbug@perl.com) cat >/tmp/c1$$ <<EOF @@ -625,6 +625,7 @@ i_grp='' i_iconv='' i_ieeefp='' i_inttypes='' +i_libutil='' i_limits='' i_locale='' i_machcthr='' @@ -14372,6 +14373,10 @@ eval $inhdr set ieeefp.h i_ieeefp eval $inhdr +: see if this is a libutil.h system +set libutil.h i_libutil +eval $inhdr + : see if locale.h is available set locale.h i_locale eval $inhdr @@ -15681,6 +15686,7 @@ i_grp='$i_grp' i_iconv='$i_iconv' i_ieeefp='$i_ieeefp' i_inttypes='$i_inttypes' +i_libutil='$i_libutil' i_limits='$i_limits' i_locale='$i_locale' i_machcthr='$i_machcthr' diff --git a/config_h.SH b/config_h.SH index 70aaefe2f2..e66e0c5ed0 100644 --- a/config_h.SH +++ b/config_h.SH @@ -3156,5 +3156,11 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #define PERL_XS_APIVERSION "$xs_apiversion" #define PERL_PM_APIVERSION "$pm_apiversion" +/* I_LIBUTIL: + * This symbol, if defined, indicates that <libutil.h> exists and + * should be included. + */ +#$i_libutil I_LIBUTIL /**/ + #endif !GROK!THIS! @@ -1999,6 +1999,30 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) break; #ifndef MACOS_TRADITIONAL case '0': +#ifdef HAS_SETPROCTITLE + /* The BSDs don't show the argv[] in ps(1) output, they + * show a string from the process struct and provide + * the setproctitle() routine to manipulate that. */ + { + s = SvPV(sv, len); +# if __FreeBSD_version >= 400000 + /* The - removes the "perl: " prefix, + * but not the "(perl) suffix from the ps(1) + * output, because that's what ps(1) shows if the + * argv[] is modified. */ + setproctitle("-%s", s, len + 1); +# else /* old FreeBSDs, NetBSD, OpenBSD */ + /* This doesn't really work if you assume that + * $0 = 'foobar'; will wipe out 'perl' from the $0 + * because in ps(1) output the result will be like + * sprintf("perl: %s (perl)", s) + * I guess this is a security feature: + * one (a user process) cannot get rid of the original name. + * --jhi */ + setproctitle("%s", s); +# endif + } +#endif if (!PL_origalen) { s = PL_origargv[0]; s += strlen(s); @@ -2054,9 +2078,6 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) for (i = 1; i < PL_origargc; i++) PL_origargv[i] = Nullch; } -#ifdef HAS_SETPROCTITLE - setproctitle("%s", SvPV_nolen(sv)); -#endif break; #endif #ifdef USE_THREADS @@ -3324,6 +3324,10 @@ typedef struct am_table_short AMTS; #endif /* IAMSUID */ +#ifdef I_LIBUTIL +# include <libutil.h> /* setproctitle() in some FreeBSDs */ +#endif + /* and finally... */ #define PERL_PATCHLEVEL_H_IMPLICIT #include "patchlevel.h" diff --git a/pod/perlvar.pod b/pod/perlvar.pod index 15308e45aa..e75cf35f73 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -691,6 +691,11 @@ program sees. This 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 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. + =item $[ The index of the first element in an array, and of the first character |