这与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 +++
如您所见,在strace
中运行时,该过程以退出状态0(已安装软件包)完成。但是,在strace
之外工作时,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
现在我的问题是:什么能解释dpkg
程序在strace
中运行时的行为不同?
答案 0 :(得分:0)
我记得以前曾在互联网上讨论过这个问题:)
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
现在应该可以在您的系统上运行。