-
Notifications
You must be signed in to change notification settings - Fork 154
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
A recent commit I LGTM'd causes unit tests to fail on macOS but not FreeBSD #110
Comments
Ksh can use sockets to implement pipes. I suggest you to look into this code. |
I think there are problems with these socket attributes on macOS. |
I'd suggest being careful with changing to using sockets. The socket interface used on RHEL 7 has been nothing but a broken mess, yet Red Hat refuses to change the ksh default on their system back to pipes out of fear, I was told:
Two problems I ran across with ksh on RHEL 7. First one: Second one is a some sort of race that reproduces less frequently the more CPUs you have in the system, but locking ksh to one CPU easily shows it: These problems reproduce with the ksh shipping with RHEL 7.4 as well as att/ast version on master branch. I have a lot more detail on both problems. Just ask if curious. I would love to know if these problems happen on other OSes (Linux and non-Linux) and what the underlying causes are. |
This is not an issue with sockets. It is a race condtion beause ksh uses |
Ah, that's right. That one wasn't a socket vs. pipe problem, but the posix_spawn() race. I take it there's no answer to Brian Ginn's question about, "Is there a reliable way to for a process to determine if it is running in the background?" |
The AST feature testing in this situation is so wrong it's amazing. Look at this block of code from src/lib/libast/features/fcntl.c:
You can't arbitrarily define syscall constants like that! Jeebus H. Christ! Those fallback definitions are why this issue exists. This bogosity was papered over by the code in the recently removed src/lib/libast/port/intercept.c module. The removed On macOS the correct value for |
Also, not to derail this issue, but |
It turns out that passing |
AFAIK |
Switching to real pipes gives these test failures. So it looks like real pipes were not well tested. |
Sockets were definitely faster than pipes back in the days of SVR2 and BSD 4.2. Mostly because they used a fixed size 8 KiB kernel buffer to shuttle the data between the read and write endpoints and weren't bidirectional. SVR4 STREAMS pipes were much more performant but obviously never got adopted by other OS's. I have no idea what the situation is today but will try to find out. The one thing that really annoys me (more than the stupid |
Also, it's interesting to note that |
It looks like the performance of |
The `SOCK_CLOEXEC` symbol is not available on some of the platforms we want to support such as macOS. It's also wrong if it's missing to define it with a specific value. Instead just use `fcntl()` to set the close-on-exec attribute. Also, remove `SOCK_NONBLOCK` because it too is nonstandard and isn't actually needed to build ksh. Fixes #110
Most of these fixes are for typos and extra whitespace at the end of lines. These are the notable changes: - Fixed a compatibility issue with how asterisks are displayed using certain fonts. Bug report: att#764 - Fixed a bug in the man page that caused searches for the '|' character to fail. Bug report: att#871 - Removed a duplicate description of 'set -B' from the man page. Bug report: att#789 - Added documentation for options missing from the ksh man page (applies to 'hist -N', 'sleep -s', 'whence -q' and many of ulimit's options). Bug reports: att#948 att#503 (comment) att#507 (comment) - Applied the following ksh2020 documentation fixes: att#351 att#352 - Fixed a minor GCC -Wformat warning in procopen.c by changing a sentinel to NULL.
I gave a LGTM to commit 8ba041a since building with that change succeeded and gave me a
ksh
command I could run on macOS and FreeBSD. However, I didn't run the unit tests. I just noticed, as part of testing the fix for issue #7, that those tests fail on macOS but not FreeBSD. The output ofbin/package test ast-ksh
on macOS begins with the following and not a single test passes:That first line is probably the important one.
The text was updated successfully, but these errors were encountered: