Skip to content

Add resolving of $PROGRAM_NAME from /dev/fd/number #23358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ Michael Somos <[email protected]>
Michael Stevens <[email protected]>
Michael van Elst <[email protected]>
Michael Witten <[email protected]>
Michal Josef Špaček <[email protected]>
Michele Sardo
Michiel Beijen <[email protected]>
Mik Firestone <[email protected]>
Expand Down
13 changes: 13 additions & 0 deletions perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4227,6 +4227,19 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, bool *suidscript)
Safefree(PL_origfilename);
PL_origfilename = (char *)scriptname;
}
else {
char proc_fd_path[64];
snprintf(proc_fd_path, sizeof(proc_fd_path), "/proc/self/fd/%d", fdscript);
char target_path[MAXPATHLEN];
SSize_t len = readlink(proc_fd_path, target_path, sizeof(target_path) - 1);
if (len != -1) {
Stat_t statbuf;
target_path[len] = '\0';
if (PerlLIO_stat(target_path, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) {
scriptname = PL_origfilename = find_script(target_path, dosearch, NULL, 1);
}
}
}
}
}

Expand Down
Loading