• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Vibra
V2EX  ›  程序员

[求助]如何查看一个动态库被多少进程所使用

  •  
  •   Vibra · Apr 25, 2022 · 2391 views
    This topic created in 1481 days ago, the information mentioned may be changed or developed.

    公司部署业务, 因为 libc 库不匹配, 所以把这个库降级了, 要求查看会不会影响别的进程, 这个怎么看, 求大佬们赐教

    8 replies    2022-04-26 14:37:41 +08:00
    lovelylain
        1
    lovelylain  
       Apr 25, 2022 via Android
    为什么不 docker
    yanqiyu
        2
    yanqiyu  
       Apr 25, 2022   ❤️ 1
    libc 的话大概可以认为影响所有动态连接的程序
    Vibra
        3
    Vibra  
    OP
       Apr 25, 2022
    @jobmailcn 因为影响的是 apt
    lesismal
        4
    lesismal  
       Apr 25, 2022   ❤️ 1
    遍历下 /proc 下所有进程的 /pid/maps ,grep 每个进程的内存空间看看哪些打开了这个 so ,细节楼主自己完善下:

    find ./ -type d -maxdepth 1 | awk '{if(substr($0,3) ~ /^[0-9]+$/) print $0"/maps";}' | awk '{if(-f $0) print $0}'| xargs grep "your absolute path of .so" | awk '{split($0,a,"/"); print a[2]}' | uniq | awk '{if($0 ~/^[0-9]+$/) print "./"$0"/exe"}' | xargs ls -l | awk '{split($0,a," "); print a[11]}'
    hhhfhhf
        5
    hhhfhhf  
       Apr 25, 2022 via iPhone
    ldd 挨个看看二进制的依赖?
    Brian1900
        6
    Brian1900  
       Apr 26, 2022
    好问题
    hxndg
        7
    hxndg  
       Apr 26, 2022
    我理解 libc 是对过去兼容的,怎么确定降级能解决问题?
    而且降级可太危险
    Kasumi20
        8
    Kasumi20  
       Apr 26, 2022
    不匹配哪个程序,就把哪个程序静态编译一遍呗
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   884 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 21:28 · PVG 05:28 · LAX 14:28 · JFK 17:28
    ♥ Do have faith in what you're doing.