Skip to content
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

Doesn't really work on OSX #5

Open
tabletcorry opened this issue Jul 28, 2011 · 2 comments
Open

Doesn't really work on OSX #5

tabletcorry opened this issue Jul 28, 2011 · 2 comments

Comments

@tabletcorry
Copy link

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...

  • Uses #!/bin/bash
    • This prevents usage of a newer bash in the PATH, which is needed since you use new bash features.
  • Uses GNU features of sed, readlink, and ... something else (will edit this when I get home)

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
Copy link
Owner

jneen commented Jul 29, 2011

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 added a commit to tabletcorry/balls that referenced this issue Jul 29, 2011
Using `/bin/bash` to invoke bash is effective, but does not allow for
flexability. `/usr/bin/env bash` will load bash from the PATH. This
allows for the user to set the version of bash.

As for the BSD replacements, I basically detect the presence of GNU
versions of the coreutils, and if they are present, create functions
to use them in place of the BSD versions

Helps fix issue jneen#5
@tabletcorry
Copy link
Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants