| #
4c8b54f7
|
| 24-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
|
| 24-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
|
| 24-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 ...
|
| #
df268d4b
|
| 24-Jun-2025 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: add a -p mode to write the child's pid
If we're going to hold the lock, it can be useful to scribble down the pid that we spawned off to quickly associate the lock back to the process that's
lockf: add a -p mode to write the child's pid
If we're going to hold the lock, it can be useful to scribble down the pid that we spawned off to quickly associate the lock back to the process that's keeping it open.
Reviewed by: allanjude (previous version), des Differential Revision: https://reviews.freebsd.org/D51014
show more ...
|
| #
5e3934b1
|
| 24-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row.
R
usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row.
Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/
Sponsored by: Netflix
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 ...
|
| #
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 ...
|
| #
3041e695
|
| 22-Nov-2023 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: hide unavailable error with -n -s
The error message is expected, allow -s to suppress just that one since it would loosely fall under the definition of "failure to acquire the lock" described
lockf: hide unavailable error with -n -s
The error message is expected, allow -s to suppress just that one since it would loosely fall under the definition of "failure to acquire the lock" described in the manpage for the -s option.
Reviewed by: 0mp, allanjude Feedback from: des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D42711
show more ...
|
| #
1d386b48
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
| #
a1b6427a
|
| 07-Jul-2023 |
Alfonso Gregory <gfunni234@gmail.com> |
Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the cases where they do return, they have not been marked __dea
Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the cases where they do return, they have not been marked __dead2.
Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/735
show more ...
|
| #
4d846d26
|
| 10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
show more ...
|
| #
e2515283
|
| 27-Aug-2020 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: Rubicon Communications, LLC (netgate.com)
|
| #
437bab48
|
| 26-Aug-2020 |
Colin Percival <cperciva@FreeBSD.org> |
Add -w option to lockf(1).
By default, lockf(1) opens its lock file O_RDONLY|O_EXLOCK. On NFS, if the file already exists, this is split into opening the file read-only and then requesting an exclu
Add -w option to lockf(1).
By default, lockf(1) opens its lock file O_RDONLY|O_EXLOCK. On NFS, if the file already exists, this is split into opening the file read-only and then requesting an exclusive lock -- and the second step fails because NFS does not permit exclusive locking on files which are opened read-only.
The new -w option changes the open flags to O_WRONLY|O_EXLOCK, allowing it to work on NFS -- at the cost of not working if the file cannot be opened for writing.
(Whether the traditional BSD behaviour of allowing exclusive locks to be obtained on a file which cannot be opened for writing is a good idea is perhaps questionable since it may allow less-privileged users to perform a local denial of service; however this behaviour has been present for a long time and changing it now seems like it would cause problems.)
Reviewed by: rmacklem Differential Revision: https://reviews.freebsd.org/D26005
show more ...
|
| #
f9856d08
|
| 20-Mar-2019 |
Alan Somers <asomers@FreeBSD.org> |
MFHead @345353
|
| #
d614ded6
|
| 20-Mar-2019 |
Andriy Voskoboinyk <avos@FreeBSD.org> |
lockf(1): return EX_UNAVAILABLE if -n is used and the lock file does not exist
Apply EX_UNAVAILABLE patch part from PR 170775 to match the documentation.
Checked with a command from PR 210770: lock
lockf(1): return EX_UNAVAILABLE if -n is used and the lock file does not exist
Apply EX_UNAVAILABLE patch part from PR 170775 to match the documentation.
Checked with a command from PR 210770: lockf -n /tmp/doesnotexist echo; echo $?
PR: 210770 MFC after: 1 week
show more ...
|
| #
4c8b54f7
|
| 24-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
|
| 24-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
|
| 24-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 ...
|
| #
df268d4b
|
| 24-Jun-2025 |
Kyle Evans <kevans@FreeBSD.org> |
lockf: add a -p mode to write the child's pid
If we're going to hold the lock, it can be useful to scribble down the pid that we spawned off to quickly associate the lock back to the process that's
lockf: add a -p mode to write the child's pid
If we're going to hold the lock, it can be useful to scribble down the pid that we spawned off to quickly associate the lock back to the process that's keeping it open.
Reviewed by: allanjude (previous version), des Differential Revision: https://reviews.freebsd.org/D51014
show more ...
|
| #
5e3934b1
|
| 24-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row.
R
usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row.
Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/
Sponsored by: Netflix
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 ...
|
| #
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 ...
|