代码之家  ›  专栏  ›  技术社区  ›  Sylvain Leroux

什么能使程序在strace中有不同的行为?

  •  1
  • Sylvain Leroux  · 技术社区  · 6 年前

    https://unix.stackexchange.com/q/485682/40697 但我决定采取更面向开发人员的方法。

    由于某些原因,当通过蓝牙串行控制台登录时,我无法在系统上安装软件包:

    # dpkg -i /var/cache/apt/archives/openssh-server_1%3a7.4p1-10+deb9u4_armhf.deb 
    dpkg: unrecoverable fatal error, aborting:
     wait for subprocess dpkg-split failed: No child processes
    

    我试图用 strace . 然而:

    # strace -e trace=fork dpkg -i /var/cache/apt/archives/openssh-server_1%3a7.4p1-10+deb9u4_armhf.deb
    [...]
    --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=7046, si_uid=0, si_status=0, si_utime=0, si_stime=1} ---
    +++ exited with 0 +++
    

    斯特拉斯 该过程用退出状态0完成(并且安装了包)。但在外面工作时 , dpkg

    FWIW,在里面跑步时 gdb 这个过程也失败了:

    # gdb /usr/bin/dpkg
    (gdb) run -i /var/cache/apt/archives/openssh-server_1%3a7.4p1-10+deb9u4_armhf.deb 
    Starting program: /usr/bin/dpkg -i /var/cache/apt/archives/openssh-server_1%3a7.4p1-10+deb9u4_armhf.deb
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
    dpkg: unrecoverable fatal error, aborting:
     wait for subprocess dpkg-split failed: No child processes
    


    现在我的问题是:什么能解释 程序在内部运行时行为不同 斯特拉斯 ?

    1 回复  |  直到 6 年前
        1
  •  0
  •   hek2mgl    6 年前

    我记得以前在网上讨论过:)

    https://github.com/strace/strace/issues/14

    dpkg_path="$(which dpkg)"
    mv -v "${dpkg_path}" /usr/bin/dpkg-orig
    
    > "{dpkg_path}" cat << 'EOF'
    #!/bin/bash
    # pro-tip: You could use a slow disk or an old usb stick
    # if writes to /dev/null turn out to be too fast
    exec strace -e trace=none -e signal=none -qq -o /dev/null /usr/bin/dpkg-orig "${@}"
    EOF
    
    chmod +x "${dpkg_path}"
    

    dpkg 现在应该可以用你的系统了。