in reply to syswrite and STDOUT

I believe that tye is on the correct path, but I'm curious about the system you're on.

syswrite() is supposed to return the number of bytes actually written and not chocke if there are too much of them. Also, note that syswrite() could return 0 without implying an error (which is signaled by undef). I believe that Linux write(2) actually works like this.

AFAIK, POSIX requires the minimum buffer size for pipes and stuff like that to be at least 512. Most modern system should support greater buffers, and this is why tye uses 4096 (which I remember to be the default size in Linux). To be on the safest side I'd stick to 512, but you could be on a non-POSIX system and need to adjust your aim :)

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.

Replies are listed 'Best First'.
Re^2: syswrite and STDOUT (guess)
by tye (Sage) on Apr 29, 2005 at 15:28 UTC

    Win32 was mentioned in the CB. I suspect that reporting $^E instead of just $! might be more instructive. But it isn't just the buffer size of the pipe (which defines how much can be sent atomically); I'm assuming that the amount of data is so much that the kernel exhausted some resource trying to buffer it all. I find it surprising that this would happen (and I doubt it would on Unix), but that was the best guess I could come up with.

    - tye        

      But it isn't just the buffer size of the pipe (which defines how much can be sent atomically); I'm assuming that the amount of data is so much that the kernel exhausted some resource trying to buffer it all.
      You're right, I merged the concepts, even if some lurking inside the 2.4.x Linux kernel convinced me that Linux considers them to be the same, as far as I can remember.

      Anyway, the fractioned approach you suggest should be used more generally - testing if write/syswrite actually wrote all requested characters should become an habit much like testing if open was successful.

      Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

      Don't fool yourself.