summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-06-29 15:41:05 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-06-29 15:41:05 +0000
commit54bfe034ba642318cf2c7d0b37579f30adef144a (patch)
tree9d4a1a11a7d2ea0e6bab798b52a7d08ff374981a /perl.c
parent52d59bef96c881381bce1bcb84a8c08ce48c2544 (diff)
downloadperl-54bfe034ba642318cf2c7d0b37579f30adef144a.tar.gz
The joy of $0. Undoing the #16399 makes Andreas'
tests (see [perl #22811]) pass (yes, padding with space instead of nul makes no sense, but that seems to work, maybe Linux does some deep magic in ps(1)?); moving the PL_origalen computation earlier makes also the threaded-first case fully pass. But in general modifying the argv[] is very non-portable. (e.g. in Tru64 it seems to be limited to the size of the original argv[0] since the argv[] are not contiguous?) Everybody should just have setproctitle(). p4raw-id: //depot/perl@19884
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/perl.c b/perl.c
index bb45684638..2f07f4cb80 100644
--- a/perl.c
+++ b/perl.c
@@ -933,6 +933,43 @@ setuid perl scripts securely.\n");
PL_origargc = argc;
PL_origargv = argv;
+ {
+ char *s = PL_origargv[0];
+ int i;
+
+ s += strlen(s);
+ /* See if all the arguments are contiguous in memory */
+ for (i = 1; i < PL_origargc; i++) {
+ if (PL_origargv[i] == s + 1
+#ifdef OS2
+ || PL_origargv[i] == s + 2
+#endif
+ )
+ {
+ ++s;
+ s += strlen(s); /* this one is ok too */
+ }
+ else
+ break;
+ }
+ /* Can we grab env area too to be used as the area for $0
+ * (in case we later modify it)? */
+ if (PL_origenviron
+ && (PL_origenviron[0] == s + 1))
+ {
+ my_setenv("NoNe SuCh", Nullch);
+ /* force copy of environment */
+ for (i = 0; PL_origenviron[i]; i++)
+ if (PL_origenviron[i] == s + 1) {
+ ++s;
+ s += strlen(s);
+ }
+ else
+ break;
+ }
+ PL_origalen = s - PL_origargv[0];
+ }
+
if (PL_do_undump) {
/* Come here if running an undumped a.out. */