`apt-get`, `dpkg`는 블루투스 직렬 포트에서는 실패하지만 물리적으로 연결된 콘솔에서는 성공합니다.

`apt-get`, `dpkg`는 블루투스 직렬 포트에서는 실패하지만 물리적으로 연결된 콘솔에서는 성공합니다.

Linux에서 일부 명령이 시스템에 연결된 콘솔에서는 실행될 수 있지만 직렬 콘솔에서는 실행될 수 없는 이유를 설명할 수 있는 구성 설정이나 기능이 있습니까?


원격 시스템이 RaspberryPi이기 때문에 여기에 게시하지만 그렇지 않습니다.생각하다이 질문은 이것과 관련이 있습니다. 나는 이 문제가 다른 데비안(그리고 아마도 다른 리눅스) 시스템에서도 일어날 수 있다고 생각합니다.

Bluetooth 직렬 포트를 통해 원격 시스템에 로그인하면 apt-get update일부 패키지 관리 관련 명령에서 오류가 발생합니다.

Raspbian GNU/Linux 9 raspberry pi rfcomm0
raspberrypi login: pi
Password:
Last login: Mon Dec  3 12:31:11 UTC 2018 on rfcomm0
Linux raspberrypi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
pi@raspberrypi:~$ sudo bash
root@raspberrypi:/home/pi# apt-get update
Hit:1 http://archive.raspbian.org/raspbian stretch InRelease
Err:1 http://archive.raspbian.org/raspbian stretch InRelease
  Waited for apt-key but it wasn't there
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://archive.raspbian.org/raspbian stretch InRelease: Waited for apt-key but it wasn't there
W: Failed to fetch http://archive.raspbian.org/raspbian/dists/stretch/InRelease  Waited for apt-key but it wasn't there
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@raspberrypi:/home/pi# 
root@raspberrypi:/home/pi# dpkg -i /var/cache/apt/archives/apt-utils_1.4.8_armhf.deb 
dpkg: unrecoverable fatal error, aborting:
 wait for subprocess dpkg-split failed: No child processes

원격 시스템 콘솔에서 동일한 명령을 직접 실행하면 다음이 생성됩니다.아니요오류가 발생하고 원활하게 작동하지 않습니다. 이 보드에는 Bluetooth 설정 이외의 구성 변경 없이 기본 Raspbian 시스템이 설치된 상태로 제공됩니다.

pi@raspberrypi:~$ who -a
           system boot  1970-01-01 00:00
           run-level 5  2018-12-03 12:29
pi       - tty1         2018-12-03 12:29 00:53         674
pi       - rfcomm0      2018-12-03 13:27   .          1906
pi@raspberrypi:~$ pstree
systemd─┬─avahi-daemon───avahi-daemon
        ├─bluetoothd
        ├─cron
        ├─dbus-daemon
        ├─dhcpcd
        ├─hciattach
        ├─login───bash───sudo───bash   < XXX apt-* works from here
        ├─rfcomm───login───bash        <     but not from here
        ├─rsyslogd─┬─{in:imklog}
        │          ├─{in:imuxsock}
        │          └─{rs:main Q:Reg}
        ├─systemd───(sd-pam)
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-timesyn───{sd-resolve}
        ├─systemd-udevd
        ├─thd
        └─wpa_supplicant

이것이 재현 가능합니까 아니면 다른 RPi입니까? 그러나 나는 진짜 데비안 시스템을 테스트할 여분의 x86 시스템이 없었습니다.


편집하다:이것은 훨씬 더 말도 안되는 일입니다. strace를 사용하여 문제를 추적하려고 시도했지만 다음과 같습니다.

# apt-get install -y openssh-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libva-wayland1
Use 'apt autoremove' to remove it.
Suggested packages:
  molly-guard monkeysphere rssh ssh-askpass ufw
The following NEW packages will be installed:
  openssh-server
0 upgraded, 1 newly installed, 0 to remove and 114 not upgraded.
Need to get 0 B/301 kB of archives.
After this operation, 833 kB of additional disk space will be used.
E: Waited for /usr/bin/apt-listchanges --apt || test $? -lt 10 but it wasn't there
E: Failure running script /usr/bin/apt-listchanges --apt || test $? -lt 10
# strace apt-get install -y openssh-server
[...]
[long list of system calls]
[...]
munmap(0x74c0d000, 2269184)             = 0
munmap(0x74a56000, 1798144)             = 0
close(3)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

보시다시피 실행이 상태 0(성공)으로 종료되었으며 패키지가 올바르게 설치되었습니다 apt-get. strace"외부적으로" 실행하면 strace작동하지 않나요? ! ?


이 질문은 나의 모든 조사를 좌절시켰습니다. /var/log/syslog, /var/log/auth 또는 Journalctl에 어떤 단서도 표시되지 않습니다. 만일을 대비해 APT 캐시를 지웠지만 오류 메시지가 거짓으로 느껴지고 일부 하위 프로세스를 생성할 수 없다는 생각이 들었습니다. PAM과 관련이 있는 것으로 의심되지만 확신할 수 없습니다.

답변1

저는 Raspbian Stretch와 함께 Raspberry Pi Zero W를 사용하고 있습니다. Bluetooth 직렬 콘솔을 통해 로그인 하면 sudo apt-get update똑같은 Waited for apt-key but it wasn't there오류 메시지가 나타납니다. 위의 게시물을 찾을 때까지 이것은 나를 미치게 만들었습니다.

strace에서 실행하면 여러분과 마찬가지로 저에게도 잘 작동합니다. 그러나 strace에서 apt-get을 실행하는 것은 매우 불만족스럽습니다. 왜냐하면 strace는 매우 시끄럽고 apt-get이 말하는 내용을 읽을 수 없게 만들기 때문입니다.

Bluetooth 직렬 콘솔을 사용하여 Raspberry Pi의 WiFi IP 주소를 찾은 다음 SSH를 통해 Raspberry Pi에 로그인할 수 있었습니다. sudo apt-get updateSSH를 통해 성공적으로 수행 할 수 있었습니다 . 이는 문제에 대한 가능한 해결 방법입니다. ssh localhostWiFi를 사용하고 싶지 않은 경우에도 작동합니다.

두 번째 해결 방법은 Bluetooth 직렬 콘솔을 통해 Raspberry Pi에 로그인하고 screenRaspberry Pi에서 실행하는 것입니다. 일단 들어가면 블루투스를 통해 직렬 콘솔을 실행할 screen수 있습니다 !sudo apt-get update

터미널 에뮬레이션에 어떤 문제가 있는 것 같지만 확실하지 않습니다. Bluetooth 직렬 포트를 통해 Raspberry Pi에 처음 연결할 때 screen또는 아래와 같은 녹색 명령 프롬프트가 표시 되지 않습니다 ssh. 다음 줄에서 bluetooth rfcomm 직렬 콘솔을 설정하는 방식에 문제가 있을 수 있습니다 ExecStart=.

/etc/systemd/system/rfcomm.service

[Unit]
Description=RFCOMM service
After=bluetooth.service
Requires=bluetooth.service

[Service]
ExecStart=/usr/bin/rfcomm watch hci0 1 setsid /sbin/agetty -8 --noreset -s -w -L rfcomm0 115200 vt100 -a pi

[Install]
WantedBy=multi-user.target

ExecStart=줄을 다음으로 변경하면 멋진 녹색 명령 프롬프트가 표시됩니다.

ExecStart=/usr/bin/rfcomm watch hci0 1 setsid /sbin/agetty -8 --noclear -s -w -L rfcomm0 115200 linux -a pi

이 파일을 변경한 후에는 재부팅해야 적용된다는 점에 유의하세요. 충분 하지 않은 것 같습니다 sudo systemctl reload rfcomm.service.

불행하게도 이제 멋진 녹색 명령 프롬프트가 있음에도 불구하고 sudo apt-get update/에서 실행하지 않으면 여전히 끔찍한 오류가 발생합니다!Waited for apt-key but it wasn't therestracescreenssh

답변2

waitpid이는 SIGCHLD 신호 및 rfcomm setid getty가 컨텍스트에서 작동하는 방식과 관련이 있습니다. 나는 POSIX 의미론, 제어 터미널, 신호 처리기에 대해 더 구체적으로 알지 못하지만 문제는 아마도 어떻게 추적될 수 있을 것이라고 생각합니다.무선 주파수 통신또는설정값fork()/waitpid()가 호출되고 있거나 SIGCHLD가 처리되지 않습니다.

나는 SO 질문에서 이 작은 프로그램을 실험하여 이 결론에 도달했습니다.waitpid() 프로세스 그룹을 기다리는 동안 하위 프로세스 오류가 없습니다.블루투스 직렬 터미널([rfcomm setid getty] 아래) 내부에서 실행하면 다른 동작을 보여줍니다. [rfcomm setid getty screen]에서는 "중단"되고 [rfcomm setid getty screen]에서는 "작동"합니다.

// cc -o wp wp.c
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int main(int argc, char **argv)
{
    pid_t pid, wpid;
    int stat;

    if ((pid = fork()))
    {
        printf("PARENT: %d | CHILD: %d\n", getpid(), pid);
        wpid = waitpid(-getpid(), &stat, 0);
        printf("DONE: wpid %d errno %d %m\n", wpid, errno);
    }
    else
    {
        printf("CHILD pid: %d\n", getpid());
        sleep(1);
    }
    return 0;
}

다양한 명령의 실패 결과:

  • wp(위의 waitpid 테스트 프로그램)
    • "완료: wpid -1 errno 10 하위 프로세스 없음"
  • crontab -e
    • 종료 인쇄 시 루프에 멈춤 "crontab: waitpid()가 "/usr/bin/sensible-editor"에서 PID 20864를 기다리는 데 실패했습니다: 하위 프로세스 없음"
  • apt-get update
    • "apt-key를 기다리는 중이지만 존재하지 않습니다."
  • git clone https://git.savannah.gnu.org/git/screen.git
    • "오류: 인덱스 패키지에 대한 waitpid 실패: 하위 프로세스 없음"
    • 흥미롭게도 git clone git://git.savannah.gnu.org/screen아주 잘 작동합니다.
    • "GNU/screen에서 실행할 때 작동합니다"라고 하면 screen의 소스 코드에서 이유를 찾으려고 노력했지만 아무 것도 생각나지 않았습니다.

노트

  • 로그인한 후 /bin/dash를 호출하면 /bin/bash 또는 /bin/bash --login을 실행해도 도움이 되지 않지만 모든 명령이 화면 밖에서 작동하는 방식과 비슷하게 잘 작동합니다.
  • waitpid 테스트는 다음과 같이 대시 "작업 제어 활성화" 매개변수 -m을 사용하여 실행될 때 작동합니다./bin/dash -m -c "~/src/wp/wp"

신호에 영향을 미칠 수 있으므로 "Control TTY"가 관련되어 있는지 배제하고 싶습니다. /dev/rfcomm0을 open()할 때 O_NOCTTY 플래그를 사용하는 rfcomm이 보입니다. 실험 결과 setsid --ctty더 나쁜 동작이 나타났으며 아직 이를 변경해 본 적이 없습니다.rfcomm.c 소스 코드. (다시)읽고 있어요TTY 공개저자: Linus Akkeson, 더 많은 것을 배우려고 노력 중입니다.

나는 이것이 대답이 아니며 SE가 포럼이 아니라는 것을 알고 있지만 이것이 누군가에게 도움이 되기를 바라며 논평할 만한 평판이 충분하지 않기를 바랍니다.

관련 정보