jneen / balls

Bash on Balls
MIT License
858 stars 44 forks source link

Doesn't really work on OSX #5

Open tabletcorry opened 13 years ago

tabletcorry commented 13 years ago

There are a few major issues that cause it to break on OSX. I have patches for most of them but the last might be impossible...

These are the easy ones to fix, and I will add a patch later today.

The real stinker though is the buffering that occurs within the pipes. In the primary code loop (that actually contains the nc call in server.sh) there are a set of pipes that buffer the data that flow through them. While I assume this is not an issue on linux, it seems that OSX will buffer quite a lot of data in these pipes. I could only get pages to flush when they were quite long. The standard 404 page would not flush until I added several K of text (I did not actually search for the magic number, just poured a bunch of text in).

Intense googling only revealed solutions that worked on Linux. Unless anyone has any ideas, I am not sure if small responses will work on OSX.

jneen commented 13 years ago

Ha, yeah, thanks for catching these. The GNU-isms are a little hard to work around, although it's possible to do some feature-testing at the beginning and create wrapper functions for things that are just slightly different. My hunch is that many of the uses of sed, etc. could be replaced with clever uses of expr, but I'd have to dig a little further first.

I'll have to spend some time with the pipe buffering issues - I wonder if there's a way to force it to flush periodically, or change a file attribute to reduce the buffer size...?

tabletcorry commented 13 years ago

The pipe buffer issue is very difficult to solve. A hint as to how to do it is the stdbuf tool in GNU coreutils. It was written specifically to resolve this issue, but does not compile on OSX...

I actually talked this over with a kernel developer, and they suggested stty. I tried this out, but could not get the results I was looking for. He then suggested that I use a real programming language as this issue is libc dependent :)

Unfortunately, most people that have pipe buffering issues only come up with solutions that work on linux.

The most hackish way to solve the problem would be to always pump out huge messages, possibly by padding with a character that the browser will ignore (or just not render).