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
}
}