From 2982a345b7a1edb63720282eef0fba5c61d0e6b5 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 21 Sep 2011 14:32:58 +0200 Subject: Where available, use sysctl() with KERN_PROC_PATHNAME to make $^X absolute. In Configure, check whether sysctl() and KERN_PROC_PATHNAME can be used to find the absolute pathname of the executable. If so, set usekernprocpathname in config.sh and USE_KERN_PROC_PATHNAME in config.h. If this is set, then use this approach in S_set_caret_X() to canonicalise $^X as an absolute path. This approach works on (at least) FreeBSD, and doesn't rely on the /proc filesystem existing, or /proc/curproc/file being present. --- Configure | 117 ++++++++++++++++++++++++++++++++++++++++++++++ Cross/config.sh-arm-linux | 1 + NetWare/config.wc | 1 + Porting/Glossary | 5 ++ Porting/config.sh | 1 + config_h.SH | 7 +++ configure.com | 1 + epoc/config.sh | 1 + perl.c | 26 ++++++++++- plan9/config_sh.sample | 1 + symbian/config.sh | 1 + t/op/magic.t | 5 +- uconfig.h | 11 ++++- uconfig.sh | 1 + uconfig64.sh | 1 + win32/config.ce | 1 + win32/config.gc | 1 + win32/config.gc64 | 1 + win32/config.gc64nox | 1 + win32/config.vc | 1 + win32/config.vc64 | 1 + 21 files changed, 181 insertions(+), 5 deletions(-) diff --git a/Configure b/Configure index 42a0a19ee8..691bd81964 100755 --- a/Configure +++ b/Configure @@ -1234,6 +1234,7 @@ usesocks='' d_oldpthreads='' use5005threads='' useithreads='' +usekernprocpathname='' usereentrant='' usethreads='' incpath='' @@ -19346,6 +19347,121 @@ $rm_try set ebcdic eval $setvar +: Determine if we can use sysctl with KERN_PROC_PATHNAME to find executing program +echo " " +echo "Determining whether we can use sysctl with KERN_PROC_PATHNAME to find executing program..." >&4 +$cat >try.c <<'EOM' +/* Intentionally a long probe as I'd like to sanity check that the exact + approach is going to work, as thinking it will work, but only having it + part working at runtime is worse than not having it. */ + +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) { + char *buffer; + char *argv_leaf = strrchr(argv[0], '/'); + char *buffer_leaf; + size_t size = 0; + int mib[4]; + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PATHNAME; + mib[3] = -1; + + if (!argv_leaf) { + fprintf(stderr, "Can't locate / in '%s'\n", argv[0]); + return 1; + } + + if (sysctl(mib, 4, NULL, &size, NULL, 0)) { + perror("sysctl"); + return 2; + } + + if (size < strlen(argv_leaf) + 1) { + fprintf(stderr, "size %lu is too short for a path\n", + (unsigned long) size); + return 3; + } + + if (size > MAXPATHLEN * MAXPATHLEN) { + fprintf(stderr, "size %lu is too long for a path\n", + (unsigned long) size); + return 4; + } + + buffer = malloc(size); + if (!buffer) { + perror("malloc"); + return 5; + } + + if (sysctl(mib, 4, buffer, &size, NULL, 0)) { + perror("sysctl"); + return 6; + } + + if (strlen(buffer) + 1 != size) { + fprintf(stderr, "size != strlen(buffer) + 1 (%lu != %lu)\n", + (unsigned long)size, (unsigned long)strlen(buffer) + 1); + return 7; + } + + + if (*buffer != '/') { + fprintf(stderr, "Not an absolute path: '%s'\n", buffer); + return 8; + } + + if (strstr(buffer, "/./")) { + fprintf(stderr, "Contains /./: '%s'\n", buffer); + return 9; + } + + if (strstr(buffer, "/../")) { + fprintf(stderr, "Contains /../: '%s'\n", buffer); + return 10; + } + + buffer_leaf = strrchr(buffer, '/'); + if (strcmp(buffer_leaf, argv_leaf) != 0) { + fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], buffer); + return 11; + } + + free(buffer); + + return 0; +} +EOM + +val=$undef +set try +if eval $compile_ok; then + if $run ./try; then + echo "You can use sysctl with KERN_PROC_PATHNAME to find the executing program." >&4 + val="$define" + else + echo "Nope, sysctl with KERN_PROC_PATHNAME doesn't work here." >&4 + val="$undef" + fi +else + echo "I'm unable to compile the test program." >&4 + echo "I'll assume no sysctl with KERN_PROC_PATHNAME here." >&4 + val="$undef" +fi +$rm_try +set usekernprocpathname +eval $setvar + : Check how to flush echo " " $cat >&4 <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un */ #$ebcdic EBCDIC /**/ +/* USE_KERN_PROC_PATHNAME: + * This symbol, if defined, indicates that we can use sysctl with + * KERN_PROC_PATHNAME to get a full path for the executable, and hence + * convert $^X to an absolute path. + */ +#$usekernprocpathname USE_KERN_PROC_PATHNAME /**/ + /* Fpos_t: * This symbol holds the type used to declare file positions in libc. * It can be fpos_t, long, uint, etc... It may be necessary to include diff --git a/configure.com b/configure.com index 14a73f1fc4..a58f77e863 100644 --- a/configure.com +++ b/configure.com @@ -6717,6 +6717,7 @@ $ WC "usefaststdio='" + usefaststdio + "'" $ WC "useieee='" + useieee + "'" ! VMS-specific $ WC "useithreads='" + useithreads + "'" $ WC "usekernelthreads='" + usekernelthreads + "'" ! VMS-specific +$ WC "usekernprocpathname='undef'" $ WC "uselargefiles='" + uselargefiles + "'" $ WC "uselongdouble='" + uselongdouble + "'" $ WC "usemorebits='" + usemorebits + "'" diff --git a/epoc/config.sh b/epoc/config.sh index 87dce8aed4..b71d62ea44 100644 --- a/epoc/config.sh +++ b/epoc/config.sh @@ -983,6 +983,7 @@ usedl='undef' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='undef' diff --git a/perl.c b/perl.c index 0b3d9c6723..5d2159d089 100644 --- a/perl.c +++ b/perl.c @@ -38,6 +38,10 @@ #include "nwutil.h" #endif +#ifdef USE_KERN_PROC_PATHNAME +# include +#endif + #ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP # ifdef I_SYSUIO # include @@ -1390,7 +1394,27 @@ S_set_caret_X(pTHX) { #if defined(OS2) sv_setpv(caret_x, os2_execname(aTHX)); #else -# ifdef HAS_PROCSELFEXE +# ifdef USE_KERN_PROC_PATHNAME + size_t size = 0; + int mib[4]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PATHNAME; + mib[3] = -1; + + if (sysctl(mib, 4, NULL, &size, NULL, 0) == 0 + && size > 0 && size < MAXPATHLEN * MAXPATHLEN) { + sv_grow(caret_x, size); + + if (sysctl(mib, 4, SvPVX(caret_x), &size, NULL, 0) == 0 + && size > 2) { + SvPOK_only(caret_x); + SvCUR_set(caret_x, size - 1); + SvTAINT(caret_x); + return; + } + } +# elif defined(HAS_PROCSELFEXE) char buf[MAXPATHLEN]; int len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1); diff --git a/plan9/config_sh.sample b/plan9/config_sh.sample index 2f7e938115..b87320dfec 100644 --- a/plan9/config_sh.sample +++ b/plan9/config_sh.sample @@ -995,6 +995,7 @@ usedl='undef' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='define' uselongdouble='undef' usemallocwrap='undef' diff --git a/symbian/config.sh b/symbian/config.sh index 6a27ff5064..c72d8c387a 100644 --- a/symbian/config.sh +++ b/symbian/config.sh @@ -810,6 +810,7 @@ usedl='undef' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='define' diff --git a/t/op/magic.t b/t/op/magic.t index dd6d28e1bd..5569154fcd 100644 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -230,10 +230,11 @@ $$ = $pid; # Tests below use $$ # $^X and $0 { + my $is_abs = $Config{d_procselfexe} || $Config{usekernprocpathname}; if ($^O eq 'qnx') { chomp($wd = `/usr/bin/fullpath -t`); } - elsif($Is_Cygwin || $Config{'d_procselfexe'}) { + elsif($Is_Cygwin || $is_abs) { # Cygwin turns the symlink into the real file chomp($wd = `pwd`); $wd =~ s#/t$##; @@ -248,7 +249,7 @@ $$ = $pid; # Tests below use $$ else { $wd = '.'; } - my $perl = $Is_VMS || $Config{d_procselfexe} ? $^X : "$wd/perl"; + my $perl = $Is_VMS || $is_abs ? $^X : "$wd/perl"; my $headmaybe = ''; my $middlemaybe = ''; my $tailmaybe = ''; diff --git a/uconfig.h b/uconfig.h index 1013423664..c5f19f7e08 100644 --- a/uconfig.h +++ b/uconfig.h @@ -2656,6 +2656,13 @@ */ /*#define EBCDIC / **/ +/* USE_KERN_PROC_PATHNAME: + * This symbol, if defined, indicates that we can use sysctl with + * KERN_PROC_PATHNAME to get a full path for the executable, and hence + * convert $^X to an absolute path. + */ +/*#define USE_KERN_PROC_PATHNAME / **/ + /* Fpos_t: * This symbol holds the type used to declare file positions in libc. * It can be fpos_t, long, uint, etc... It may be necessary to include @@ -4704,6 +4711,6 @@ #endif /* Generated from: - * 5c3a0864433ad4da7f3248b108cf8e17c19bd4d71799cd56b6c2a73bb647561a config_h.SH - * e5d6d7ffdf6717946996c0807aa7a247b46adf41f2d98c62cdd7c1bb8ffe19f2 uconfig.sh + * e6513dfa5f1449ab9266aee521d6d5908873d1dc68bf4f049316ebc4921732e1 config_h.SH + * e940950d07a2be0354d6ae7e4316ec8465ed581607bbb958d8bfda024b9941fe uconfig.sh * ex: set ro: */ diff --git a/uconfig.sh b/uconfig.sh index 74a1b9143e..ee84d35603 100644 --- a/uconfig.sh +++ b/uconfig.sh @@ -777,6 +777,7 @@ usedl='undef' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='undef' diff --git a/uconfig64.sh b/uconfig64.sh index 784d0f010e..e3346e7787 100644 --- a/uconfig64.sh +++ b/uconfig64.sh @@ -778,6 +778,7 @@ usedl='undef' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='undef' diff --git a/win32/config.ce b/win32/config.ce index 1f58933459..8028928dee 100644 --- a/win32/config.ce +++ b/win32/config.ce @@ -977,6 +977,7 @@ usedl='define' usedtrace='undef' usefaststdio='undef' useithreads='~USE_ITHREADS~' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='define' diff --git a/win32/config.gc b/win32/config.gc index 5741584252..ff6eb6f725 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -1020,6 +1020,7 @@ usedl='define' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='define' diff --git a/win32/config.gc64 b/win32/config.gc64 index bc6210e558..e46b55af9d 100644 --- a/win32/config.gc64 +++ b/win32/config.gc64 @@ -1021,6 +1021,7 @@ usedl='define' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='define' diff --git a/win32/config.gc64nox b/win32/config.gc64nox index fc407ad7aa..82226e9cdd 100644 --- a/win32/config.gc64nox +++ b/win32/config.gc64nox @@ -1021,6 +1021,7 @@ usedl='define' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='define' diff --git a/win32/config.vc b/win32/config.vc index 30957919e1..f57805789c 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -1020,6 +1020,7 @@ usedl='define' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='define' diff --git a/win32/config.vc64 b/win32/config.vc64 index 1396a0ad00..86b404044f 100644 --- a/win32/config.vc64 +++ b/win32/config.vc64 @@ -1020,6 +1020,7 @@ usedl='define' usedtrace='undef' usefaststdio='undef' useithreads='undef' +usekernprocpathname='undef' uselargefiles='undef' uselongdouble='undef' usemallocwrap='define' -- cgit v1.2.1 From ae60cb464cebf89579ec0ff91db8b792b2f1e7cd Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 21 Sep 2011 15:33:09 +0100 Subject: Where available, use _NSGetExecutablePath() to make $^X absolute. In Configure, check whether _NSGetExecutablePath() can be used to find the absolute pathname of the executable. If so, set usensgetexecutablepath in config.sh and USE_NSGETEXECUTABLEPATH in config.h. If this is set, then use this approach in S_set_caret_X() to canonicalise $^X as an absolute path. This approach works on OS X, and possible on other platforms that use dyld. --- Configure | 102 ++++++++++++++++++++++++++++++++++++++++++++++ Cross/config.sh-arm-linux | 1 + NetWare/config.wc | 1 + Porting/Glossary | 5 +++ Porting/config.sh | 1 + config_h.SH | 7 ++++ configure.com | 1 + epoc/config.sh | 1 + perl.c | 24 +++++++++++ plan9/config_sh.sample | 1 + symbian/config.sh | 1 + t/op/magic.t | 3 +- uconfig.h | 11 ++++- uconfig.sh | 1 + uconfig64.sh | 1 + win32/config.ce | 1 + win32/config.gc | 1 + win32/config.gc64 | 1 + win32/config.gc64nox | 1 + win32/config.vc | 1 + win32/config.vc64 | 1 + 21 files changed, 164 insertions(+), 3 deletions(-) diff --git a/Configure b/Configure index 691bd81964..1f0dbefee4 100755 --- a/Configure +++ b/Configure @@ -1229,6 +1229,7 @@ nm_opt='' nm_so_opt='' runnm='' usenm='' +usensgetexecutablepath='' useperlio='' usesocks='' d_oldpthreads='' @@ -19462,6 +19463,106 @@ $rm_try set usekernprocpathname eval $setvar +: Determine if we can use _NSGetExecutablePath to find executing program +echo " " +echo "Determining whether we can use _NSGetExecutablePath to find executing program..." >&4 +$cat >try.c <<'EOM' +/* Intentionally a long probe as I'd like to sanity check that the exact + approach is going to work, as thinking it will work, but only having it + part working at runtime is worse than not having it. */ +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) { + char buf[1]; + uint32_t size = sizeof(buf); + int result; + char *buffer; + char *tidied; + char *argv_leaf = strrchr(argv[0], '/'); + char *tidied_leaf; + + if (!argv_leaf) { + fprintf(stderr, "Can't locate / in '%s'\n", argv[0]); + return 1; + } + + _NSGetExecutablePath(buf, &size); + if (size > MAXPATHLEN * MAXPATHLEN) { + fprintf(stderr, "_NSGetExecutablePath size %u is too long for a path\n", + (unsigned int) size); + return 2; + } + + buffer = malloc(size); + if (!buffer) { + perror("malloc"); + return 3; + } + + result = _NSGetExecutablePath(buffer, &size); + if (result != 0) { + fprintf(stderr, "_NSGetExecutablePath returned %i for a size of %u\n", + result, (unsigned int) size); + return 4; + } + + tidied = realpath(buffer, NULL); + if (!tidied) { + perror("realpath"); + return 5; + } + + free(buffer); + + if (*tidied != '/') { + fprintf(stderr, "Not an absolute path: '%s'\n", tidied); + return 6; + } + + if (strstr(tidied, "/./")) { + fprintf(stderr, "Contains /./: '%s'\n", tidied); + return 7; + } + + if (strstr(tidied, "/../")) { + fprintf(stderr, "Contains /../: '%s'\n", tidied); + return 8; + } + + tidied_leaf = strrchr(tidied, '/'); + if (strcmp(tidied_leaf, argv_leaf) != 0) { + fprintf(stderr, "Leafnames differ: '%s' vs '%s'\n", argv[0], tidied); + return 9; + } + + free(tidied); + + return 0; +} +EOM + +val=$undef +set try +if eval $compile_ok; then + if $run ./try; then + echo "You can use _NSGetExecutablePath to find the executing program." >&4 + val="$define" + else + echo "Nope, _NSGetExecutablePath doesn't work here." >&4 + fi +else + echo "I'm unable to compile the test program." >&4 + echo "I'll assume no _NSGetExecutablePath here." >&4 +fi +$rm_try +set usensgetexecutablepath +eval $setvar + : Check how to flush echo " " $cat >&4 <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un */ #$usekernprocpathname USE_KERN_PROC_PATHNAME /**/ +/* USE_NSGETEXECUTABLEPATH: + * This symbol, if defined, indicates that we can use _NSGetExecutablePath + * and realpath to get a full path for the executable, and hence convert + * $^X to an absolute path. + */ +#$usensgetexecutablepath USE_NSGETEXECUTABLEPATH /**/ + /* Fpos_t: * This symbol holds the type used to declare file positions in libc. * It can be fpos_t, long, uint, etc... It may be necessary to include diff --git a/configure.com b/configure.com index a58f77e863..5da59730bc 100644 --- a/configure.com +++ b/configure.com @@ -6718,6 +6718,7 @@ $ WC "useieee='" + useieee + "'" ! VMS-specific $ WC "useithreads='" + useithreads + "'" $ WC "usekernelthreads='" + usekernelthreads + "'" ! VMS-specific $ WC "usekernprocpathname='undef'" +$ WC "usensgetexecutablepath='undef'" $ WC "uselargefiles='" + uselargefiles + "'" $ WC "uselongdouble='" + uselongdouble + "'" $ WC "usemorebits='" + usemorebits + "'" diff --git a/epoc/config.sh b/epoc/config.sh index b71d62ea44..c80589005e 100644 --- a/epoc/config.sh +++ b/epoc/config.sh @@ -991,6 +991,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='' +usensgetexecutablepath='undef' useopcode='' useperlio='undef' useposix='' diff --git a/perl.c b/perl.c index 5d2159d089..4285834173 100644 --- a/perl.c +++ b/perl.c @@ -42,6 +42,10 @@ # include #endif +#ifdef USE_NSGETEXECUTABLEPATH +# include +#endif + #ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP # ifdef I_SYSUIO # include @@ -1414,6 +1418,26 @@ S_set_caret_X(pTHX) { return; } } +# elif defined(USE_NSGETEXECUTABLEPATH) + char buf[1]; + uint32_t size = sizeof(buf); + int result; + + _NSGetExecutablePath(buf, &size); + if (size < MAXPATHLEN * MAXPATHLEN) { + sv_grow(caret_x, size); + if (_NSGetExecutablePath(SvPVX(caret_x), &size) == 0) { + char *const tidied = realpath(SvPVX(caret_x), NULL); + if (tidied) { + sv_setpv(caret_x, tidied); + free(tidied); + } else { + SvPOK_only(caret_x); + SvCUR_set(caret_x, size); + } + return; + } + } # elif defined(HAS_PROCSELFEXE) char buf[MAXPATHLEN]; int len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1); diff --git a/plan9/config_sh.sample b/plan9/config_sh.sample index b87320dfec..bd5da2fa14 100644 --- a/plan9/config_sh.sample +++ b/plan9/config_sh.sample @@ -1003,6 +1003,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='y' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='define' useposix='true' diff --git a/symbian/config.sh b/symbian/config.sh index c72d8c387a..a62577b820 100644 --- a/symbian/config.sh +++ b/symbian/config.sh @@ -818,6 +818,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='define' useposix='true' diff --git a/t/op/magic.t b/t/op/magic.t index 5569154fcd..8c2c508f57 100644 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -230,7 +230,8 @@ $$ = $pid; # Tests below use $$ # $^X and $0 { - my $is_abs = $Config{d_procselfexe} || $Config{usekernprocpathname}; + my $is_abs = $Config{d_procselfexe} || $Config{usekernprocpathname} + || $Config{usensgetexecutablepath}; if ($^O eq 'qnx') { chomp($wd = `/usr/bin/fullpath -t`); } diff --git a/uconfig.h b/uconfig.h index c5f19f7e08..c3799020da 100644 --- a/uconfig.h +++ b/uconfig.h @@ -2663,6 +2663,13 @@ */ /*#define USE_KERN_PROC_PATHNAME / **/ +/* USE_NSGETEXECUTABLEPATH: + * This symbol, if defined, indicates that we can use _NSGetExecutablePath + * and realpath to get a full path for the executable, and hence convert + * $^X to an absolute path. + */ +/*#define USE_NSGETEXECUTABLEPATH / **/ + /* Fpos_t: * This symbol holds the type used to declare file positions in libc. * It can be fpos_t, long, uint, etc... It may be necessary to include @@ -4711,6 +4718,6 @@ #endif /* Generated from: - * e6513dfa5f1449ab9266aee521d6d5908873d1dc68bf4f049316ebc4921732e1 config_h.SH - * e940950d07a2be0354d6ae7e4316ec8465ed581607bbb958d8bfda024b9941fe uconfig.sh + * 5b5dacbb00f53ae9b440c79cf6d5c8bbf80a7adfa1db3f3814aa77dc6f461fa7 config_h.SH + * b5e74633486412bbc4d2a1c3847f3e85b10a86e96fb5d1efb7b8bc885956d746 uconfig.sh * ex: set ro: */ diff --git a/uconfig.sh b/uconfig.sh index ee84d35603..e7692dc693 100644 --- a/uconfig.sh +++ b/uconfig.sh @@ -785,6 +785,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='undef' useposix='true' diff --git a/uconfig64.sh b/uconfig64.sh index e3346e7787..1ae544fbcd 100644 --- a/uconfig64.sh +++ b/uconfig64.sh @@ -786,6 +786,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='undef' useposix='true' diff --git a/win32/config.ce b/win32/config.ce index 8028928dee..62d2123605 100644 --- a/win32/config.ce +++ b/win32/config.ce @@ -985,6 +985,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='~USE_PERLIO~' useposix='true' diff --git a/win32/config.gc b/win32/config.gc index ff6eb6f725..cb963fb6fa 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -1028,6 +1028,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='undef' useposix='true' diff --git a/win32/config.gc64 b/win32/config.gc64 index e46b55af9d..7e06e2a9fd 100644 --- a/win32/config.gc64 +++ b/win32/config.gc64 @@ -1029,6 +1029,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='undef' useposix='true' diff --git a/win32/config.gc64nox b/win32/config.gc64nox index 82226e9cdd..92ef05f5a7 100644 --- a/win32/config.gc64nox +++ b/win32/config.gc64nox @@ -1029,6 +1029,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='undef' useposix='true' diff --git a/win32/config.vc b/win32/config.vc index f57805789c..379a125bab 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -1028,6 +1028,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='undef' useposix='true' diff --git a/win32/config.vc64 b/win32/config.vc64 index 86b404044f..d429f2028c 100644 --- a/win32/config.vc64 +++ b/win32/config.vc64 @@ -1028,6 +1028,7 @@ usemorebits='undef' usemultiplicity='undef' usemymalloc='n' usenm='false' +usensgetexecutablepath='undef' useopcode='true' useperlio='undef' useposix='true' -- cgit v1.2.1 From 698ca84cd388c82246e9cc3789248bc413591374 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 27 Sep 2011 23:47:39 +0200 Subject: In Configure, refactor the test for procselfexe into a loop. This removes code duplication, and makes it easy to add more variants. Based on a patch from Johann 'Myrkraverk' Oskarsson. --- Configure | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Configure b/Configure index 1f0dbefee4..80923f6060 100755 --- a/Configure +++ b/Configure @@ -16047,23 +16047,22 @@ echo " " procselfexe='' val="$undef" case "$d_readlink" in -"$define") - if $issymlink /proc/self/exe ; then - $ls -l /proc/self/exe > reflect - if $contains /`basename $ls` reflect >/dev/null 2>&1; then - echo "You have Linux-like /proc/self/exe." - procselfexe='"/proc/self/exe"' - val="$define" - fi - fi - if $issymlink /proc/curproc/file ; then - $ls -l /proc/curproc/file > reflect + "$define") + set Linux /proc/self/exe BSD /proc/curproc/file + while test $# -gt 0; do + type=$1; try=$2 + shift; shift + if $issymlink $try; then + $ls -l $try > reflect if $contains /`basename $ls` reflect >/dev/null 2>&1; then - echo "You have BSD-like /proc/curproc/file." - procselfexe='"/proc/curproc/file"' - val="$define" + echo "You have $type-like $try." + procselfexe='"'$try'"' + val="$define" + : This will break out of the loop + set X; shift fi - fi + fi + done ;; esac $rm -f reflect -- cgit v1.2.1 From 9e68546f79174957f317b4b7abcf8be457602a6d Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 28 Sep 2011 00:15:32 +0200 Subject: Teach Configure about "procselfexe" on Solaris and NetBSD Configure would already find /proc/self/exe on NetBSD, where /proc/self is a symlink to /proc/curproc. However, the revised probe avoids the extra symlink traversal. Configure did not previously probe for the relevant path on Solaris, /proc/self/path/a.out Rename the description of /proc/curproc/file from BSD to FreeBSD, as it seems that of the "big 3" BSDs, only FreeBSD uses this path. Based on a patch from Johann 'Myrkraverk' Oskarsson. --- Configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Configure b/Configure index 80923f6060..fe2fcc9afe 100755 --- a/Configure +++ b/Configure @@ -16048,7 +16048,9 @@ procselfexe='' val="$undef" case "$d_readlink" in "$define") - set Linux /proc/self/exe BSD /proc/curproc/file + : NetBSD first as /proc/self is a symlink to /proc/curproc, and it feels + : more tidy to avoid an extra level of symlink + set NetBSD /proc/curproc/exe Linux /proc/self/exe FreeBSD /proc/curproc/file Solaris /proc/self/path/a.out while test $# -gt 0; do type=$1; try=$2 shift; shift -- cgit v1.2.1 From 3f728e2e43e05f9eb833343447d126327b7dee56 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 28 Sep 2011 10:54:44 +0200 Subject: Note the improved $^X absolute pathname conversion in perldelta.pod --- pod/perldelta.pod | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 32fdb7a97d..825288e510 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -22,11 +22,15 @@ XXX Any important notices here =head1 Core Enhancements -XXX New core language features go here. Summarise user-visible core language -enhancements. Particularly prominent performance optimisations could go -here, but most should go in the L section. +=head2 $^X converted to an absolute path on FreeBSD, OS X and Solaris -[ List each enhancement as a =head2 entry ] +C<$^X> is now converted to an absolute path on OS X, FreeBSD (without +needing F mounted) and Solaris 10 and 11. This augments the +previous approach of using F on Linux, FreeBSD and NetBSD +(in all cases, where mounted). + +This makes relocatable perl installations more useful on these platforms. +(See "Relocatable @INC" in F) =head1 Security -- cgit v1.2.1