| 4c8b54f7 | 25-Jun-2025 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: minor cosmetic cleanups, no functional change
Switch various flags from int -> bool.
kill(getpid(), foo) and raise(foo) are equivalent in this context, so switch to the latter as a minor pre
lockf: minor cosmetic cleanups, no functional change
Switch various flags from int -> bool.
kill(getpid(), foo) and raise(foo) are equivalent in this context, so switch to the latter as a minor preference for readability.
Use proper signal fences instead of volatile for our SIGALRM handler.
Reviewed by: kib (earlier version), des Differential Revision: https://reviews.freebsd.org/D51027
show more ...
|
| 679f6194 | 25-Jun-2025 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: add a -T option to terminate the child upon early abort
This is useful to avoid having the command running twice in the face of the admin terminating the process. Notably, if the -p option i
lockf: add a -T option to terminate the child upon early abort
This is useful to avoid having the command running twice in the face of the admin terminating the process. Notably, if the -p option is not in use (or can't be used, e.g., because we can't open the file for writing) then this provides a nice alternative where one simply needs to send a SIGTERM to the lockf(1) process associated with the lock file to clean it all up.
Reviewed by: des Differential Revision: https://reviews.freebsd.org/D51025
show more ...
|
| 7e8afac0 | 25-Jun-2025 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: switch to a SIGCHLD model for reaping child
A future change will add a -T flag to forward SIGTERM along to the child before we cleanup and terminate ourselves. Using a SIGCHLD handler to do
lockf: switch to a SIGCHLD model for reaping child
A future change will add a -T flag to forward SIGTERM along to the child before we cleanup and terminate ourselves. Using a SIGCHLD handler to do that with SIGTERM blocked only while the child is actively being collected will enable us to safely do so without having to worry that our pid is potentially invalid.
Add a test that concisely checks that the child's error is properly bubbled up to the caller.
Reviewed by: des, kib Differential Revision: https://reviews.freebsd.org/D51024
show more ...
|
| e4967d4d | 26-Nov-2023 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: switch to strtonum() for parsing timeout
Convert waitsec to a long long to be able to hold the full domain of alarm(3) timeout on all platforms, and let strtonum(3) handle the input validatio
lockf: switch to strtonum() for parsing timeout
Convert waitsec to a long long to be able to hold the full domain of alarm(3) timeout on all platforms, and let strtonum(3) handle the input validation. strtonum(3) also happens to provide a neater interface for error handling, and it already includes our pre-existing empty input check.
Sponsored by: Klara, Inc.
show more ...
|
| 09a7fe0a | 22-Nov-2023 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: allow locking file descriptors
This is most useful inside a shell script, allowing one to lock just portions of a script rather than having to wrap the entire script in a lock.
PR: 262738 R
lockf: allow locking file descriptors
This is most useful inside a shell script, allowing one to lock just portions of a script rather than having to wrap the entire script in a lock.
PR: 262738 Reviewed by: 0mp, allanjude (both previous versions) Co-authored-by: Daniel O'Connor <darius@dons.net.au> Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D42718
show more ...
|
| 296a5a4d | 22-Nov-2023 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: add some tests
Provide basic coverage for the existing options, nothing deeper (e.g., pipe closing behavior) is tested in this set.
Reviewed by: allanjude Feedback from: des Sponsored by: Kl
lockf: add some tests
Provide basic coverage for the existing options, nothing deeper (e.g., pipe closing behavior) is tested in this set.
Reviewed by: allanjude Feedback from: des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D42714
show more ...
|
| 18425c19 | 22-Nov-2023 |
Alexander Melkov <melkov@comptek.ru> |
lockf: don't hold stdin/stdout/stderr open
None of these are essential in the lockf monitor (parent post-fork), so close them to maintain the illusion that lockf hasn't been inserted into the pipeli
lockf: don't hold stdin/stdout/stderr open
None of these are essential in the lockf monitor (parent post-fork), so close them to maintain the illusion that lockf hasn't been inserted into the pipeline. This ensures that the correct effects happen on other programs in the pipeline if the locked command closes or redirects these elsewhere.
The original patch used -s to close stdout/stderr rather than closing them unconditionally, but it's not clear that we really care that much. kevans dropped that part when taking the patch, patch is otherwise by listed author.
PR: 112379 Reviewed by: 0mp, allanjude (both earlier version), kevans Feedback from: des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D42713
show more ...
|
| 35095fd2 | 22-Nov-2023 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: correct omission in the usage statement
The -w flag was added without being noted in the usage statement; fix that now.
While we're here, re-sort the getopt() string.
Reviewed by: 0mp, alla
lockf: correct omission in the usage statement
The -w flag was added without being noted in the usage statement; fix that now.
While we're here, re-sort the getopt() string.
Reviewed by: 0mp, allanjude, des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D42712
show more ...
|