通过 SSH 启动会话时,GNU 屏幕冻结,本地工作正常。出了什么问题?

通过 SSH 启动会话时,GNU 屏幕冻结,本地工作正常。出了什么问题?

在运行 Snow Leopard 的 iMac 上,我可以打开终端窗口并启动“screen”会话,没有任何问题。但是,如果我通过 ssh 进入同一台机器(从其他地方或本地),然后尝试启动“screen”会话,它就会挂起。根本没有输出。它不会响应 Ctrl-d、Ctrl-c 等,必须通过其 PID 将其终止。在本地终端中创建的会话可以从 ssh 会话中恢复。这有助于将怀疑引向任何配置吗?

我怀疑 .bashrc、.profile 等文件中的一个存在问题,但不知道哪个文件适用于这种情况,而且最近没有在该区域进行任何更改。所有这些都是以同一用户身份完成的。

我 99% 确信这在不久前是有效的,但我想这种情况在我之前没有出现过的可能性很小。

以下是 Gilles 提出的问题的回答:

两种情况下的环境变量相同。大多数都是空白的 - 仅设置了 COLUMNS、LINES、HOME、PATH、SHELL 和 TERM。

在挂起状态下,screen 根本不接受任何输入。当它被杀死时,父 shell 会接收任何用于 screen 的键盘输入。它不消耗 CPU 时间。

观察启动的两个屏幕进程,编号较低的进程正在执行以下操作:

$ sudo dtruss -p 1545
SYSCALL(args)        = return
sigreturn(0x7FFF5FBFEE80, 0x1E, 0x7FFF5FBFEE80)      = 0 Err#-2
__pthread_canceled(0x0, 0x0, 0x7FFF5FBFEF38)         = -1 Err#22
setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)       = 0 0
kill(0x60A, 0x0, 0x1)        = 0 0
sigaction(0xE, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)       = 0 0
sigprocmask(0x0, 0x0, 0x7FFF5FBFEF4C)        = 0x0 0
sigsuspend(0x0, 0x0, 0x0)        = -1 Err#4
<repeats approx every 10s>

编号较高的那个仅输出:

$ sudo dtruss -p 1546
SYSCALL(args)        = return

删除重复项后的 dtruss -f -p $pid_of_bash_that_starts_screen 输出为:

1500/0x15a94:  write_nocancel(0x2, "s\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "c\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "c\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "r\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "r\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "e\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "e\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "e\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "e\0", 0x1)       = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  read(0x0, "n\0", 0x1)         = 1 0
1500/0x15a94:  write_nocancel(0x2, "n\352\277_\377\177\0", 0x1)      = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x0, 0x7FFF5FBFEB00)         = 0x0 0
1500/0x15a94:  sigaltstack(0x0, 0x7FFF5FBFEAF0, 0x0)         = 0 0
1500/0x15a94:  fork()        = 1635 0
1500/0x15a94:  setpgid(0x663, 0x663, 0x5DD)      = 0 0
1500/0x15a94:  sigprocmask(0x3, 0x7FFF5FBFF9C8, 0x0)         = 0x0 0
1500/0x15a94:  sigprocmask(0x1, 0x7FFF5FBFFA8C, 0x7FFF5FBFFA88)      = 0x0 0
1500/0x15a94:  sigprocmask(0x1, 0x7FFF5FBFFA2C, 0x7FFF5FBFFA28)      = 0x0 0
1500/0x15a94:  ioctl(0xFF, 0x4004667A, 0x7FFF5FBFF97C)       = 0 0
1500/0x15a94:  ioctl(0xFF, 0x80047476, 0x7FFF5FBFF9FC)       = 0 0
1500/0x15a94:  sigprocmask(0x3, 0x7FFF5FBFFA28, 0x0)         = 0x0 0
1500/0x15a94:  sigprocmask(0x3, 0x7FFF5FBFFA88, 0x0)         = 0x0 0
1500/0x15a94:  sigprocmask(0x1, 0x7FFF5FBFFA8C, 0x7FFF5FBFFA88)      = 0x0 0
1635/0x1654c:  ioctl(0x3, 0x80086804, 0x7FFF5FBFD6A0)        = 0 0
1635/0x1654c:  close(0x3)        = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD590, 0x2, 0x7FFF5FBFD580)         = 0 0
1635/0x1654c:  bsdthread_register(0x7FFF82BA42FC, 0x7FFF82B84F18, 0x2000)        = 0 0
1635/0x1654c:  thread_selfid(0x7FFF82BA42FC, 0x7FFF82B84F18, 0x0)        = 91468 0
1635/0x1654c:  open_nocancel("/dev/urandom\0", 0x0, 0x7FFF705D1B60)      = 3 0
1635/0x1654c:  read_nocancel(0x3, "g\307\017\235\330=\212e\272\357o\351\207\365\207\0023Ra^\372\344z8\nf\253\205\335\177v\261\365\241pj\360rNW\333\344\331\300\250W\f\273O&<\232\257\034^\350!\n\351&\231P\\\025\0", 0x40)       = 64 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  mmap(0x0, 0x3000, 0x3, 0x1002, 0x1000000, 0x7FFF00000001)         = 0x59000 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD410, 0x2, 0x7FFF5FBFD3D0)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD3D0, 0x2, 0x7FFF5FBFD468)         = 0 0
1635/0x1654c:  getpid(0x7FFF5FBFD360, 0x7FFFFFE00050, 0x0)       = 1635 0
1635/0x1654c:  open_nocancel("/dev/urandom\0", 0x0, 0x0)         = 3 0
1635/0x1654c:  read_nocancel(0x3, ":juq\236\223OW\305\231,\002\205\235E\346_\236>H\t\026=\213\220\\\020\tN?\240\254\361\262q<e\300M\252\200le<\241$\027\377\252Xs\034\355\212+#z+\241\033I\346s\017\227\244\351\227\024\272\361\263Qn\315\354U\312\211\017\313\265\f\033I\341\300\372Id\327\251tB\016\026/(\313\214\266\242S\275\351\372Y{\0", 0x6C)         = 108 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD410, 0x2, 0x7FFF5FBFD43C)         = 0 0
1635/0x1654c:  mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x7FFF00000001)         = 0x5C000 0
1635/0x1654c:  mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x7FFF00000001)         = 0x69000 0
1635/0x1654c:  mmap(0x0, 0x1000, 0x3, 0x1002, 0x1000000, 0x7FFF00000001)         = 0x76000 0
1635/0x1654c:  mmap(0x0, 0x200000, 0x3, 0x1002, 0x7000000, 0x7FFF00000001)       = 0x77000 0
1635/0x1654c:  munmap(0x100077000, 0x89000)      = 0 0
1635/0x1654c:  munmap(0x100200000, 0x77000)      = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD570, 0x2, 0x7FFF5FBFD530)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD530, 0x2, 0x7FFF705DE6C0)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD570, 0x2, 0x7FFF5FBFD530)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD530, 0x2, 0x7FFF705DE6C4)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD570, 0x2, 0x7FFF5FBFD530)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD530, 0x2, 0x7FFF705DE6C8)         = 0 0
1635/0x1654c:  getdtablesize(0x0, 0x7FFF5FBFFA40, 0x0)       = 256 0
1635/0x1654c:  close(0xFF)       = -1 Err#9
...
1635/0x1654c:  close(0x3)        = -1 Err#9
1635/0x1654c:  getuid(0x10002D277, 0xFFFFFFFFFFFFFFFF, 0x7FFF5FBFF3D1)       = 502 0
1635/0x1654c:  getgid(0x10002D277, 0xFFFFFFFFFFFFFFFF, 0x0)      = 20 0
1635/0x1654c:  geteuid(0x10002D277, 0xFFFFFFFFFFFFFFFF, 0x0)         = 502 0
1635/0x1654c:  getegid(0x10002D277, 0xFFFFFFFFFFFFFFFF, 0x0)         = 20 0
1635/0x1654c:  sigaction(0x19, 0x7FFF5FBFF200, 0x7FFF5FBFF240)       = 0 0
1635/0x1654c:  sigaction(0xD, 0x7FFF5FBFF200, 0x7FFF5FBFF240)        = 0 0
1635/0x1654c:  access("/Users/chris/.nethackrc\0", 0x0, 0x17)        = -1 Err#2
1635/0x1654c:  getlogin(0x7FFF705D05A0, 0xFF, 0xFFFFFFFFFFFFFFFF)        = 0 0
1635/0x1654c:  mmap(0x0, 0x1000000, 0x3, 0x1002, 0x2000000, 0x100000000)         = 0x200000 0
1635/0x1654c:  munmap(0x100200000, 0x600000)         = 0 0
1635/0x1654c:  munmap(0x101000000, 0x200000)         = 0 0
1635/0x1654c:  shm_open(0x7FFF82CBF980, 0x0, 0x0)        = 3 0
1635/0x1654c:  mmap(0x0, 0x1000, 0x1, 0x1, 0x3, 0x100000000)         = 0x77000 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  getrlimit(0x1008, 0x7FFF5FBFEFF0, 0x7FFF82B6E86C)         = 0 0
1635/0x1654c:  open_nocancel("/etc/sysinfo.conf\0", 0x0, 0x1B6)      = -1 Err#2
1635/0x1654c:  stat64("/var/folders/jJ/jJ6dXorgFwuvL9p+qVUNVU+++TM/\0", 0x7FFF5FBFED00, 0x0)         = 0 0
1635/0x1654c:  mkdir("/var/folders/jJ/jJ6dXorgFwuvL9p+qVUNVU+++TM/-Tmp-/\0", 0x1C0, 0x7FFF5FBFEE13)      = -1 Err#17
1635/0x1654c:  access("/var/folders/jJ/jJ6dXorgFwuvL9p+qVUNVU+++TM/-Tmp-/.screen\0", 0x0, 0x3C0)         = 0 0
1635/0x1654c:  stat64("/var/folders/jJ/jJ6dXorgFwuvL9p+qVUNVU+++TM/-Tmp-/.screen\0", 0x7FFF5FBFF2C0, 0x0)        = 0 0
1635/0x1654c:  umask(0x12, 0x7FFF5FBFF2C0, 0x80808000)       = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFF110, 0x2, 0x7FFF5FBFF120)         = 0 0
1635/0x1654c:  sigaction(0x1, 0x7FFF5FBFF200, 0x7FFF5FBFF240)        = 0 0
1635/0x1654c:  fork()        = 1636 0
1635/0x1654c:  setgid(0x14, 0x7FFF5FBFF7F1, 0x10005364B)         = 0 0
1635/0x1654c:  setuid(0x1F6, 0x7FFF5FBFF7F1, 0x0)        = 0 0
1635/0x1654c:  sigaction(0x1, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  sigaction(0x1, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  sigaction(0x1E, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
1635/0x1654c:  sigaction(0x1F, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
1635/0x1654c:  sigaction(0x2, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  sigaction(0x12, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
1635/0x1654c:  sigaction(0x1C, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)       = 0 0
1635/0x1654c:  sigaction(0xE, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  sigprocmask(0x0, 0x0, 0x7FFF5FBFEF4C)         = 0x0 0
1636/0x1654e:  fstat64(0x2, 0x7FFF5FBFE5F0, 0x7FFF5FBFE6BC)      = 0 0
1636/0x1654e:  ioctl(0x2, 0x4004667A, 0x7FFF5FBFE63C)        = 0 0
1636/0x1654e:  write_nocancel(0x2, "SCREEN: can't detach from console\n\0", 0x22)        = 34 0
1635/0x1654c:  sigsuspend(0x0, 0x0, 0x0)         = -1 Err#4
1635/0x1654c:  __pthread_canceled(0x0, 0x0, 0x7FFF5FBFEF38)      = -1 Err#22
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  kill(0x664, 0x0, 0x1)         = 0 0
1635/0x1654c:  sigaction(0xE, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  sigprocmask(0x0, 0x0, 0x7FFF5FBFEF4C)         = 0x0 0
1500/0x15a94:  read(0x0, "\r\006\0", 0x1)        = 1 0
1500/0x15a94:  write_nocancel(0x2, "\n\006\0", 0x1)      = 1 0
1500/0x15a94:  sigprocmask(0x1, 0x1000A5984, 0x1000A5988)        = 0x0 0
1500/0x15a94:  ioctl(0x0, 0x80487414, 0x1000A59C0)       = 0 0
1500/0x15a94:  sigprocmask(0x3, 0x1000A5988, 0x0)        = 0x0 0
1500/0x15a94:  sigaction(0x2, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)        = 0 0
1500/0x15a94:  sigaction(0xF, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)        = 0 0
1500/0x15a94:  sigaction(0x3, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)        = 0 0
1500/0x15a94:  sigaction(0xE, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)        = 0 0
1500/0x15a94:  sigaction(0x12, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)       = 0 0
1500/0x15a94:  sigaction(0x16, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)       = 0 0
1500/0x15a94:  sigaction(0x15, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)       = 0 0
1500/0x15a94:  sigaction(0x1C, 0x7FFF5FBFEAE0, 0x7FFF5FBFEB10)       = 0 0
1500/0x15a94:  sigaction(0x2, 0x7FFF5FBFEB00, 0x7FFF5FBFEB30)        = 0 0
1500/0x15a94:  gettimeofday(0x7FFF5FBFE9D0, 0x0, 0x1F80)         = 1289128377 0
1500/0x15a94:  sigprocmask(0x1, 0x7FFF5FBFF9CC, 0x7FFF5FBFF9C8)      = 0x0 0
1635/0x1654c:  fork()        = 0 0
1635/0x1654c:  thread_selfid(0x7FFF705D4C20, 0x3, 0x1)       = 91468 0
1635/0x1654c:  getpid(0x7FFF705D4C20, 0x3, 0x0)      = 1635 0
1635/0x1654c:  sigprocmask(0x3, 0x1000A69D8, 0x0)        = 0x0 0
1635/0x1654c:  sigaction(0x12, 0x7FFF5FBFF950, 0x7FFF5FBFF980)       = 0 0
1635/0x1654c:  sigaction(0x15, 0x7FFF5FBFF950, 0x7FFF5FBFF980)       = 0 0
1635/0x1654c:  sigaction(0x16, 0x7FFF5FBFF960, 0x7FFF5FBFF990)       = 0 0
1635/0x1654c:  setpgid(0x663, 0x663, 0x0)        = 0 0
1635/0x1654c:  sigprocmask(0x1, 0x7FFF5FBFF98C, 0x7FFF5FBFF988)      = 0x0 0
1635/0x1654c:  ioctl(0xFF, 0x4004667A, 0x7FFF5FBFF8DC)       = 0 0
1635/0x1654c:  ioctl(0xFF, 0x80047476, 0x7FFF5FBFF95C)       = 0 0
1635/0x1654c:  sigprocmask(0x3, 0x7FFF5FBFF988, 0x0)         = 0x0 0
1635/0x1654c:  sigaction(0x2, 0x7FFF5FBFF950, 0x7FFF5FBFF980)        = 0 0
1635/0x1654c:  sigaction(0x3, 0x7FFF5FBFF950, 0x7FFF5FBFF980)        = 0 0
1635/0x1654c:  sigaction(0xF, 0x7FFF5FBFF950, 0x7FFF5FBFF980)        = 0 0
1635/0x1654c:  sigaction(0x14, 0x7FFF5FBFF950, 0x7FFF5FBFF980)       = 0 0
1635/0x1654c:  execve(0x1001D0C30, 0x1001D0D20, 0x1001CFC40)         = 0 0
1635/0x1654c:  gettimeofday(0x7FFF5FBFF850, 0x0, 0x7FFF5FBFFA50)         = 1289128377 0
1635/0x1654c:  getpid(0x7FFF5FBFF850, 0x0, 0x0)      = 1635 0
1635/0x1654c:  open_nocancel("/dev/urandom\0", 0x0, 0x0)         = 3 0
1635/0x1654c:  read_nocancel(0x3, "\021M\323J\242\363\227\001py\363h\331\321)\326\216\300r\n9r\b\252g\342\326\003\242\340\246\311\0", 0x6C)      = 108 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  issetugid(0x100000000, 0x7FFF5FBFFB18, 0x7FFF5FC40530)        = 0 0
1635/0x1654c:  geteuid(0x100000000, 0x7FFF5FBFFB18, 0x0)         = 502 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD740, 0x2, 0x7FFF5FBFD700)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFD700, 0x2, 0x7FFF5FBFD79C)         = 0 0
1635/0x1654c:  shared_region_check_np(0x7FFF5FBFD908, 0x0, 0x7FFF5FC1DC86)       = 0 0
1635/0x1654c:  stat64("/Applications/ImageMagick/lib/libncurses.5.4.dylib\0", 0x7FFF5FBFCE50, 0x7FFF5FBFD0F0)        = -1 Err#2
1635/0x1654c:  stat64("/usr/lib/libncurses.5.4.dylib\0", 0x7FFF5FBFCAB0, 0x7FFF5FBFD0F0)         = 0 0
1635/0x1654c:  stat64("/Applications/ImageMagick/lib/libSystem.B.dylib\0", 0x7FFF5FBFCE50, 0x7FFF5FBFD0F0)       = -1 Err#2
1635/0x1654c:  stat64("/usr/lib/libSystem.B.dylib\0", 0x7FFF5FBFCAB0, 0x7FFF5FBFD0F0)        = 0 0
1635/0x1654c:  stat64("/Applications/ImageMagick/lib/libmathCommon.A.dylib\0", 0x7FFF5FBFCBB0, 0x7FFF5FBFCE50)       = -1 Err#2
1635/0x1654c:  stat64("/usr/lib/system/libmathCommon.A.dylib\0", 0x7FFF5FBFC810, 0x7FFF5FBFCE50)         = 0 0
1635/0x1654c:  madvise(0x7FFF89561000, 0x2000, 0x5)      = 0 0
1635/0x1654c:  open("/dev/dtracehelper\0", 0x2, 0x7FFF5FC451F8)      = 3 0
1635/0x1654c:  ioctl(0x0, 0x40487413, 0x7FFF5FBFF1E0)        = 0 0
1635/0x1654c:  fstat64(0x0, 0x7FFF5FBFF150, 0x0)         = 0 0
1635/0x1654c:  open_nocancel("/dev/\0", 0x100004, 0x0)       = 3 0
1635/0x1654c:  fcntl_nocancel(0x3, 0x2, 0x1)         = 0 0
1635/0x1654c:  __sysctl(0x7FFF5FBFE5E0, 0x2, 0x7FFF705D6698)         = 0 0
1635/0x1654c:  fstatfs64(0x3, 0x7FFF5FBFE630, 0x0)       = 0 0
1635/0x1654c:  getdirentries64(0x3, 0x100801400, 0x1000)         = 3080 0
1635/0x1654c:  lstat64("/dev/.\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/..\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/console\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/tty\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/null\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/zero\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/klog\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/fd\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/stdin\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/stdout\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/stderr\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/auditpipe\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/ttyp0\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/ptyp0\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
...
1635/0x1654c:  lstat64("/dev/ttywf\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/ptywf\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/ptmx\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/vn0\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/vn1\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/vn2\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/vn3\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/bpf0\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/bpf1\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/bpf2\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/bpf3\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/fsevents\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/random\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/urandom\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/dtrace\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/dtracehelper\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/lockstat\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/sdt\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/systrace\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/machtrace\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/fbt\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/profile\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  getdirentries64(0x3, 0x100801400, 0x1000)         = 888 0
1635/0x1654c:  lstat64("/dev/pmCPUClient\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/disk0\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/rdisk0\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/disk0s1\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/rdisk0s1\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/disk0s2\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/rdisk0s2\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/io8log\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/io8logmt\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/cu.Bluetooth-Modem\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/tty.Bluetooth-Modem\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/cu.W880i-SerialPort\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/tty.W880i-SerialPort\0", 0x7FFF5FBFEF70, 0x0)       = 0 0
1635/0x1654c:  lstat64("/dev/cu.Bluetooth-PDA-Sync\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/tty.Bluetooth-PDA-Sync\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/autofs\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/autofs_nowait\0", 0x7FFF5FBFEF70, 0x0)      = 0 0
1635/0x1654c:  lstat64("/dev/autofs_control\0", 0x7FFF5FBFEF70, 0x0)         = 0 0
1635/0x1654c:  lstat64("/dev/ttys000\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  lstat64("/dev/ttys002\0", 0x7FFF5FBFEF70, 0x0)        = 0 0
1635/0x1654c:  close_nocancel(0x3)       = 0 0
1635/0x1654c:  stat64("/dev/ttys002\0", 0x7FFF5FBFF2C0, 0x7FFF705D03A0)      = 0 0
1635/0x1654c:  seteuid(0x1F6, 0x6, 0x0)      = 0 0
1635/0x1654c:  setegid(0x14, 0x6, 0x0)       = 0 0
1635/0x1654c:  open("/dev/ttys002\0", 0x6, 0x0)      = 3 0
1635/0x1654c:  seteuid(0x1F6, 0x6, 0x0)      = 0 0
1635/0x1654c:  setegid(0x14, 0x6, 0x0)       = 0 0
1635/0x1654c:  close(0x3)        = 0 0
1635/0x1654c:  ioctl(0x0, 0x40487413, 0x100053C20)       = 0 0
1635/0x1654c:  umask(0x0, 0x40487413, 0x0)       = 18 0
1635/0x1654c:  geteuid(0x1, 0x7FFF5FBFEDE0, 0x400)       = 502 0
1636/0x1654e:  fork()        = 0 0
1636/0x1654e:  thread_selfid(0x7FFF705D4C20, 0x3, 0x1)       = 91470 0
1636/0x1654e:  getpid(0x7FFF705D4C20, 0x3, 0x0)      = 1636 0
1636/0x1654e:  seteuid(0x1F6, 0x2, 0x0)      = 0 0
1636/0x1654e:  setegid(0x14, 0x2, 0x0)       = 0 0
1636/0x1654e:  open("/dev/ttys002\0", 0x2, 0x0)      = 3 0
1636/0x1654e:  seteuid(0x1F6, 0x2, 0x0)      = 0 0
1636/0x1654e:  setegid(0x14, 0x2, 0x0)       = 0 0
1636/0x1654e:  close_nocancel(0x0)       = 0 0
1636/0x1654e:  open_nocancel("/dev/null\0", 0x0, 0x1B6)      = 0 0
1636/0x1654e:  close_nocancel(0x1)       = 0 0
1636/0x1654e:  open_nocancel("/dev/null\0", 0x601, 0x1B6)        = 1 0
1636/0x1654e:  close_nocancel(0x2)       = 0 0
1636/0x1654e:  open_nocancel("/dev/null\0", 0x601, 0x1B6)        = 2 0
1636/0x1654e:  audit_session_self(0x664, 0x7FFF5FBFF228, 0x7FFF82B6B366)         = 2563 0
1635/0x1654c:  sigsuspend(0x0, 0x0, 0x0)         = -1 Err#4
1635/0x1654c:  sigreturn(0x7FFF5FBFEE80, 0x1E, 0x7FFF5FBFEE80)       = 0 Err#-2
1635/0x1654c:  __pthread_canceled(0x0, 0x0, 0x7FFF5FBFEF38)      = -1 Err#22
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  kill(0x664, 0x0, 0x1)         = 0 0
1635/0x1654c:  sigaction(0xE, 0x7FFF5FBFEF10, 0x7FFF5FBFEF50)        = 0 0
1635/0x1654c:  setitimer(0x0, 0x7FFF5FBFEF40, 0x7FFF5FBFEF20)        = 0 0
1635/0x1654c:  sigprocmask(0x0, 0x0, 0x7FFF5FBFEF4C)         = 0x0 0

答案1

你不是唯一遇到这个问题的人。屏幕因 Apple 特定的代码而挂起。似乎如果你取出这部分代码并重新编译,它就可以工作

  • 您需要安装 Apple 开发工具 (Xcode)。
  • 下载屏幕源。(有一个更新的版本,screen-19,其中你必须手动删除有问题的代码screen.c。)然后解压它:

    tar -xzf screen-16.tar.gz
    cd screen-16
    
  • 取出补丁的第一块和第三块screen.c;也就是说,patches/screen.c.diff现在应该包含

    --- screen.c    2003-09-08 07:26:41.000000000 -0700
    +++ screen.c    2009-02-13 12:05:05.000000000 -0800
    @@ -929,6 +934,16 @@
        Panic(0, "No $SCREENDIR with multi screens, please.");
     #endif
         }
    +#ifdef __APPLE__
    +    else if (!multi && real_uid == eff_uid) {
    +      static char DarwinSockDir[PATH_MAX];
    +      if (confstr(_CS_DARWIN_USER_TEMP_DIR, DarwinSockDir, sizeof(DarwinSockDir))) {
    +   strlcat(DarwinSockDir, ".screen", sizeof(DarwinSockDir));
    +   SockDir = DarwinSockDir;
    +      }
    +    }
    +#endif /* __APPLE__ */
    +
     #ifdef MULTIUSER
       if (multiattach)
         {
    
  • 现在编译代码:

    make install_source
    make
    
  • 检查生成的可执行/tmp/screen/Build/screen文件是否有效。

  • D4T3N7OD 的博客如何用您的程序替换官方屏幕可执行文件。

我不知道为什么屏幕会挂起,为什么上面的修复有效,以及删除这个补丁会有什么损失。如果有人感兴趣,以下是我追踪代码的进展。

  • Screen 派生了一个子进程,该进程/dev/null在 std{in,out,err} 上打开并调用后会冻结audit_session_self。源代码中的对应位置是screen.c其中,我们看到了对私有 Apple API 的调用:

    #if defined(__APPLE__) && !TARGET_OS_EMBEDDED
        if (_vprocmgr_detach_from_console(0) != NULL)
            errx(1, "can't detach from console");
    #endif
    
  • 此代码似乎源自苹果屏幕 11 补丁

  • 的实施_vprocmgr_detach_from_console似乎是libvproc,这将导致

    task_name_for_pid(mach_task_self(), getpid(), &tnp);
    vproc_mig_switch_to_session(bootstrap_port, tnp, (char *)target_session, _audit_session_self(), &new_bsport))
    

    这里我们识别出_audit_session_self最后一个起作用的(Darwin)系统调用。

  • 接下来是 Mach 调用switch_to_session。这就是我失去踪迹的地方。

答案2

这是在 macOS 10.12.6 中的情况(在 10.11.6 中,即使没有下面的更改,也能正常工作)

如果您通过 ssh 登录,nohup 在同一个系统调用中失败,出现 ioctl 和未定义错误,并且屏幕如上所述挂起,请在 /etc/ssh/sshd_config 中启用 UsePAM。我们发现,在 SSH 内部执行 su - $USER 然后运行 ​​screen 或 nohup 是可行的,但直接通过 ssh 登录然后运行命令则不行(除非启用了 UsePAM)。一定是有一些额外的“安全”功能/钩子导致必须启用此功能。

相关内容