Show HN: Linux CLI tool to provide mutex locks for long running bash ops
github.com
Show HN: Linux CLI tool to provide mutex locks for long running bash ops
1–10 of 22 posts
Re: Show HN: Linux CLI tool to provide mutex locks for long running bash ops
#2Re: Show HN: Linux CLI tool to provide mutex locks for long running bash ops
#3Re: Show HN: Linux CLI tool to provide mutex locks for long running bash ops
#4Re: Show HN: Linux CLI tool to provide mutex locks for long running bash ops
#5Why not https://man7.org/linux/man-pages/man2/flock.2.html ?
Re: Show HN: Linux CLI tool to provide mutex locks for long running bash ops
#6Why not https://man7.org/linux/man-pages/man2/flock.2.html ?
Nit: Probably https://man7.org/linux/man-pages/man1/flock.1.html (shell command, not the underlying libc function)
Re: Show HN: Linux CLI tool to provide mutex locks for long running bash ops
#7Why not https://man7.org/linux/man-pages/man2/flock.2.html ?
I would say one good reason is that
waitlock myapp &
JOB_PID=$!
# ... do exclusive work ...
kill $JOB_PID
is a lot easier to use and remember than (; flock -n 9 || exit 1; # ... commands executed under lock ...; ) 9>/var/lock/mylockfileRe: Show HN: Linux CLI tool to provide mutex locks for long running bash ops
#8I don’t know the exact threshold at which you should use a real programming language instead of a bash script. But this type of work definitely exceeds it.
Re: Show HN: Linux CLI tool to provide mutex locks for long running bash ops
#9Why not https://man7.org/linux/man-pages/man2/flock.2.html ?
Because that's a syscall ;) https://man7.org/linux/man-pages/man1/flock.1.html is the command line manual. I would say one good reason is that waitlock myapp & JOB_PID=$! # ... do exclusive work ... kill $JOB_PID is a lot easier to use and remember than (; flock -n 9 || exit 1; # ... commands executed under lock ...; ) 9>/var/lock/mylockfile
(; flock -n 9
and not ( flock -n 9
?Re: Show HN: Linux CLI tool to provide mutex locks for long running bash ops
#10Useful project, I love all things terminal, so I also enjoyed your project.