aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2025-09-03 09:52:07 +0200
committerKarel Zak <kzak@redhat.com>2025-09-03 09:52:07 +0200
commit7eb91dc080c980c94f15c9a5f9e3452b6a1f1fc1 (patch)
treeea8e10b8ecb48c6729f40f5de0bcddc062f4b4a6
parent1c28f8f5f391c00a3eb5c78f6a50bc520121e53b (diff)
parentdef89ba6d0daf48b18e88a3d81f75489b1bb8110 (diff)
downloadutil-linux-7eb91dc080c980c94f15c9a5f9e3452b6a1f1fc1.tar.gz
Merge branch 'feat/lslocks_output_env' of https://github.com/cgoesche/util-linux-fork
* 'feat/lslocks_output_env' of https://github.com/cgoesche/util-linux-fork: lslocks: (man) add LSLOCKS_COLUMNS description in new ENVIRONMENT section lslocks: add support for LSLOCKS_COLUMNS environmental variable
-rw-r--r--misc-utils/lslocks.8.adoc8
-rw-r--r--misc-utils/lslocks.c2
2 files changed, 10 insertions, 0 deletions
diff --git a/misc-utils/lslocks.8.adoc b/misc-utils/lslocks.8.adoc
index 743f275f39..2944e3afa0 100644
--- a/misc-utils/lslocks.8.adoc
+++ b/misc-utils/lslocks.8.adoc
@@ -112,6 +112,11 @@ The holder(s) of the lock. The format of the holder is _PID_,_COMMAND_,_FD_.
If a lock is an open file description-oriented lock, there can be more than one holder for the lock.
See the NOTES below.
+== ENVIRONMENT
+
+LSLOCKS_COLUMNS=::
+Specifies a comma-separated list of output columns to print. All columns listed by *--list-columns* can be used.
+
== NOTES
The *lslocks* command is meant to replace the *lslk*(8) command, originally written by mailto:abe@purdue.edu[Victor A. Abell] and unmaintained since 2001.
@@ -123,9 +128,12 @@ description on which they are acquired. With *fork*(2) and/or
the holder process of a lease (or a lock) is not uniquely determined.
*lslocks* shows the one of the holder processes in COMMAND and PID columns.
+The default output is subject to change. So whenever possible, you should avoid using default output in your scripts.
+
== AUTHORS
mailto:dave@gnu.org[Davidlohr Bueso]
+mailto:cgoesc2@wgu.edu[Christian Goeschel Ndjomouo]
== SEE ALSO
diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c
index 4ed3a37166..ad8da240bd 100644
--- a/misc-utils/lslocks.c
+++ b/misc-utils/lslocks.c
@@ -952,6 +952,8 @@ int main(int argc, char *argv[])
columns[ncolumns++] = COL_PATH;
}
+ if (!outarg)
+ outarg = getenv("LSLOCKS_COLUMNS");
if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns),
&ncolumns, column_name_to_id) < 0)
return EXIT_FAILURE;