-
Notifications
You must be signed in to change notification settings - Fork 19
Usability and Mac improvements #14
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
base: master
Are you sure you want to change the base?
Conversation
Adds an exit() overload and a library destructor routine that call libc_sync() when syncs have been eaten and the EATMYDATA_END_SYNC env. var is set. They also print how many syncs were swallowed, if EATMYDATA_VERBOSE is set. Committed from host : Portia.local
Committed from host : Portia.local
let the OS deallocate progName and cache nosyncs before printing, all to prevent race conditions and print something that's less likely to be wrong. Committed from host : Bola
Set EATMYDATA_END_SYNC=1 to sync only when the 1st eatmydata instance exits (libeatmydata reads and unsets the variable internally). Use EATMYDATA_END_SYNC=2 to present the variable and cause an end-sync in each child process. Also, reformat the source. Committed from host : Portia.local
EATMYDATA_END_SYNC=-1 will disable eating syncs after exit() or _exit() have been called, allowing the libc runtime to do any of the explicit syncs it wants to do. A new close() overload also starts doing explicit fsync's on the descriptors it has to close. Potential because I haven't yet seen it do any syncs or NOT eat any. Committed from host : Bola
| exe="`which "${cmd}"`" | ||
| if [ -x "$exe" ] ;then | ||
| ok="yes" | ||
| else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI, the whole point of the path-searching logic here is that you can't use which to look up the command in question — which will almost certainly return your own location, in the case where some other executable's name is symlinked to eatmydata.
i.e.: If you have $HOME/bin/git symlinked to /usr/bin/eatmydata, because you want to use libeatmydata on /usr/bin/git, then assuming $HOME/bin/ is earlier in your $PATH you can just run git clone https://github.com/stewartsmith/libeatmydata and it'll launch /usr/bin/eatmydata with $1 set to git and $2 set to https://github.com/stewartsmith/libeatmydata.
But a which git will ALWAYS RETURN $HOME/bin/git in that scenario, which is the exact thing the "avoid loops with self" code is trying to prevent.
In order to find /usr/bin/git as the real executable to launch, you have to search the $PATH yourself instead of using which.
I don't know how universally supported it is, but if the available which implementation supports the -a flag, using which -a "$cmd" (to get all commands matching $cmd on the $PATH) could be a useful way to avoid walking the $PATH manually. But each of the returned executables would still have to be checked against "`readlink -f "$exe"`" != "$self", because the first item would be expected to fail that test.
|
On Wednesday February 05 2025 20:46:43 Frank Dana wrote:
Talk about a blast from the past...
Just FYI, the whole point of the path-searching logic here is that you _can't_ use `which` to look up the command in question — `which` will almost certainly return **your own location**, in the case where some other executable's name is symlinked to `eatmydata`.
Doh, yes.
IIRC the idea here was to speed up the process. I don't know if there's a universal and robust way to determine if "$exe = $0" but there has to be one to check if "$exe" is in fact a link to `eatmydata`.
|
This is the PR announced in issue #13 . It's become a bit of a catch-all for a number of more or less (un)related changes:
EATMYDATA_END_SYNC=1to do this only in the application launched by the user, set itEATMYDATA_END_SYNC=2to do it in every child process too (that does slow things down if the child processes each do only tiny bits of work).EATMYDATA_VERBOSEto print out the number of syncs and sync modes that were swallowed. Uses a simple counter without any thread-safeties because there's nothing crucial to the feature and I don't want to introduce locks in overloads of functions that have to remain signal-safe.And, a bit stupidly: a source code reformat.