Zsh -- New Convenience func deadlibs()
authorSteve Youngs <steve@steveyoungs.com>
Sat, 29 May 2021 19:38:25 +0000 (05:38 +1000)
committerSteve Youngs <steve@steveyoungs.com>
Sat, 29 May 2021 19:45:41 +0000 (05:45 +1000)
Print a list of processes that are using now deleted libraries.  It's
output is an indication of what needs to be restarted and/or rebuilt.

* etc/pkgusr/zsh/zsh-pkgtools (deadlibs): New.  Print processes
that are using deleted libraries.
(H-pkg): Document it.

Signed-off-by: Steve Youngs <steve@steveyoungs.com>
etc/pkgusr/zsh/zsh-pkgtools

index a33dbfa..9defa36 100644 (file)
@@ -38,6 +38,8 @@ H-pkg ()
         ctar [FILE] [DIRECTORY]
                      -- create a tarball FILE of DIRECTORY.  Compression
                          is automatically chosen from the filename.
+       deadlibs [LIBNAME]
+                      -- print processes using deleted library, LIBNAME
 
 
 EOF
@@ -269,6 +271,18 @@ pkg_install()
     pkglst
 }
 
+## See what is currently using now deleted libs
+deadlibs()
+{
+    if [[ $ARGC -ne 1 ]]; then
+       echo 1>&2 Invalid or missing argument
+       echo 1>&2 "Usage: $0 [LIBNAME]"
+       return 1
+    fi
+    ssh root@localhost grep -l  -e "${argv[1]}.*deleted" /proc/*/maps |
+        tr -cd 0-9\\n | xargs -r ps --no-headers | awk '{print $5}'
+}
+
 ## Couple handy aliases
 alias pkg_ldconfig='ssh -l root localhost ldconfig'
 alias vtar=less