Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Poll: Is your $^X an absolute path? (argv[0])

by ysth (Canon)
on Aug 17, 2006 at 21:45 UTC ( [id://568032]=note: print w/replies, xml ) Need Help??


in reply to Re: Poll: Is your $^X an absolute path? (argv[0])
in thread Poll: Is your $^X an absolute path?

If you want to know what happens on those platforms, I'd look at Perl's source code rather than try to conduct a poll.
PROCSELFEXE_PATH is /proc/self/exe (Linux) or /proc/curproc/file (BSDish)
#ifdef HAS_PROCSELFEXE /* This is a function so that we don't hold on to MAXPATHLEN bytes of stack longer than necessary */ STATIC void S_procself_val(pTHX_ SV *sv, const char *arg0) { char buf[MAXPATHLEN]; int len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1); /* On Playstation2 Linux V1.0 (kernel 2.2.1) readlink(/proc/self/e +xe) includes a spurious NUL which will cause $^X to fail in system or backticks (this will prevent extensions from being built and many tests from working). readlink is not meant to add a NUL. Normal readlink works fine. */ if (len > 0 && buf[len-1] == '\0') { len--; } /* FreeBSD's implementation is acknowledged to be imperfect, somet +imes returning the text "unknown" from the readlink rather than the +path to the executable (or returning an error from the readlink). A +ny valid path has a '/' in it somewhere, so use that to validate the res +ult. See http://www.freebsd.org/cgi/query-pr.cgi?pr=35703 */ if (len > 0 && memchr(buf, '/', len)) { sv_setpvn(sv,buf,len); } else { sv_setpv(sv,arg0); } } #endif /* HAS_PROCSELFEXE */ STATIC void S_set_caret_X(pTHX) { dVAR; GV* tmpgv = gv_fetchpvs("\030", GV_ADD|GV_NOTQUAL, SVt_PV); /* $^X + */ if (tmpgv) { #ifdef HAS_PROCSELFEXE S_procself_val(aTHX_ GvSV(tmpgv), PL_origargv[0]); #else #ifdef OS2 sv_setpv(GvSVn(tmpgv), os2_execname(aTHX)); #else sv_setpv(GvSVn(tmpgv),PL_origargv[0]); #endif #endif } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://568032]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found