Like Nasreddin Hodja, I have been looking for the cause of extraneous trailing characters from perl
in cmd.exe under the lamp post. Hey, here is a file that has win32 and io in its name, therefore, it must contain all Windows related IO stuff. Sort of makes sense I guess.
Once again, Tony Cook provided the missing illumination in a different corner: “PerlIOWin32_write() is part of the :win32 layer, which is incomplete and isn’t used.”
Ouch!
But that actually nudged me to look in win32.c. Let’s see what we have here:
3322 DllExport int
3323 win32_write(int fd, const void *buf, unsigned int cnt)
3324 {
3325 return write(fd, buf, cnt);
3326 }
Changing that to:
DllExport int
win32_write(int fd, const void *buf, unsigned int cnt)
{
if ((fd == 1) || (fd == 2)) {
write(fd, buf, cnt);
return cnt;
}
else {
return write(fd, buf, cnt);
}
}
and recompiling gives:
I am not claiming this is THE solution. However, this actually enables me to verify where the intervention needs to happen.
Now, if I could just figure out how to stop reading from the console from aborting …