An alternative on linux is to $fp = fopen("/proc/self/fd/3","r+")
https://weirdan.livejournal.com/73729.html