终端关闭时分离的 GNU 屏幕会话意外终止

终端关闭时分离的 GNU 屏幕会话意外终止

GNU screen在具有相同配置的几台服务器上使用了多年,从未遇到过这个奇怪的问题:

通过 SSH 连接到服务器后,我启动screen(不带选项)。然后,无论我是否关闭终端应用程序(iTerm或者Terminal通过单击“x”或通过CMD+ )或首先使用+W 分离屏幕会话,在任何情况下屏幕进程都会被终止并且会话消失。为了调试,我已明确设置为现在,但这没有帮助。CTRLA Dautodetachon

  • 这本身不是 Ubuntu 18 问题,因为它不会出现在另一个 Ubuntu 18 VM 上
  • 这不是 iTerm2 本身的问题,因为它也显示在 Max OS Xs 终端下

命令上 strace 的输出screen -s /bin/sh -c /dev/null位于嵌套SCREEN进程上

strace -fo strace.log32231 -p 32231
strace: Process 32231 attached
strace: Process 494 attached

32231 select(1024, [3 4 5], [], NULL, NULL) = 1 (in [3])
32231 read(3, "", 4096)                 = 0
32231 close(3)                          = 0
32231 rt_sigaction(SIGHUP, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f8f459b6f20}, {sa_handler=0x55d24d7a37b0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f8f459b6f20},
8) = 0
32231 --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=1, si_uid=0} ---
32231 --- SIGCONT {si_signo=SIGCONT, si_code=SI_USER, si_pid=1, si_uid=0} ---
32231 rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f8f459b6f20}, {sa_handler=0x55d24d7a2780, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_res
torer=0x7f8f459b6f20}, 8) = 0
32231 rt_sigaction(SIGHUP, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f8f459b6f20}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f8f459b6f20}, 8) = 0
32231 access("/var/run/utmpx", F_OK)    = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/var/run/utmp", O_RDONLY|O_CLOEXEC) = 3
32231 lseek(3, 0, SEEK_SET)             = 0
32231 alarm(0)                          = 0
32231 rt_sigaction(SIGALRM, {sa_handler=0x7f8f45adbac0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f8f459b6f20}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
32231 alarm(10)                         = 0
32231 fcntl(3, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
32231 read(3, "\2\0\0\0\0\0\0\0~\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
32231 read(3, "\6\0\0\0006{\0\0console\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
32231 read(3, "\10\0\0\0004{\0\0tty2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
32231 read(3, "\10\0\0\0b|\0\0pts/0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
32231 read(3, "\7\0\0\0\347}\0\0pts/1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
32231 fcntl(3, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
32231 alarm(0)                          = 10
32231 rt_sigaction(SIGALRM, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f8f459b6f20}, NULL, 8) = 0
32231 rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f8f459b6f20}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0
x7f8f459b6f20}, 8) = 0
32231 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f8f467efa10) = 494
32231 wait4(494,  <unfinished ...>
494   dup2(5, 0)                        = 0
494   dup2(5, 1)                        = 1
494   execve("/usr/lib/x86_64-linux-gnu/utempter/utempter", ["/usr/lib/x86_64-linux-gnu/utempt"..., "del"], 0x7ffd944276a8 /* 34 vars */) = 0
494   brk(NULL)                         = 0x562af5727000
494   access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
494   access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
494   openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
494   fstat(3, {st_mode=S_IFREG|0644, st_size=50970, ...}) = 0
494   mmap(NULL, 50970, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fcee95a3000
494   close(3)                          = 0
494   access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
494   openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
494   read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\34\2\0\0\0\0\0"..., 832) = 832
494   fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
494   mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fcee95a1000
494   mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fcee8f98000
494   mprotect(0x7fcee917f000, 2097152, PROT_NONE) = 0
494   mmap(0x7fcee937f000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7fcee937f000
494   mmap(0x7fcee9385000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fcee9385000
494   close(3)                          = 0
494   arch_prctl(ARCH_SET_FS, 0x7fcee95a24c0) = 0
494   mprotect(0x7fcee937f000, 16384, PROT_READ) = 0
494   mprotect(0x562af3a05000, 4096, PROT_READ) = 0
494   mprotect(0x7fcee95b0000, 4096, PROT_READ) = 0
494   munmap(0x7fcee95a3000, 50970)     = 0
494   fstat(0, {st_mode=S_IFCHR|0666, st_rdev=makedev(5, 2), ...}) = 0
494   fstat(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(5, 2), ...}) = 0
494   fstat(2, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
494   getppid()                         = 32231
494   getuid()                          = 1001
494   brk(NULL)                         = 0x562af5727000
494   brk(0x562af5748000)               = 0x562af5748000
494   socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
494   connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
494   close(3)                          = 0
494   socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
494   connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
494   close(3)                          = 0
494   openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
494   fstat(3, {st_mode=S_IFREG|0644, st_size=497, ...}) = 0
494   read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 497
494   read(3, "", 4096)                 = 0
494   close(3)                          = 0
494   openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
494   fstat(3, {st_mode=S_IFREG|0644, st_size=50970, ...}) = 0
494   mmap(NULL, 50970, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fcee95a3000
494   close(3)                          = 0
494   access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
494   openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = 3
494   read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\22\0\0\0\0\0\0"..., 832) = 832
494   fstat(3, {st_mode=S_IFREG|0644, st_size=39744, ...}) = 0
494   mmap(NULL, 2136256, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fcee8d8e000
494   mprotect(0x7fcee8d96000, 2097152, PROT_NONE) = 0
494   mmap(0x7fcee8f96000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x8000) = 0x7fcee8f96000
494   close(3)                          = 0
494   mprotect(0x7fcee8f96000, 4096, PROT_READ) = 0
494   munmap(0x7fcee95a3000, 50970)     = 0
494   openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
494   fstat(3, {st_mode=S_IFREG|0644, st_size=50970, ...}) = 0
494   mmap(NULL, 50970, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fcee95a3000
494   close(3)                          = 0
494   access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
494   openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_nis.so.2", O_RDONLY|O_CLOEXEC) = 3
494   read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p \0\0\0\0\0\0"..., 832) = 832
494   fstat(3, {st_mode=S_IFREG|0644, st_size=47576, ...}) = 0
494   mmap(NULL, 2143624, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fcee8b82000
494   mprotect(0x7fcee8b8d000, 2093056, PROT_NONE) = 0
494   mmap(0x7fcee8d8c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa000) = 0x7fcee8d8c000
494   close(3)                          = 0
494   access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
494   openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnsl.so.1", O_RDONLY|O_CLOEXEC) = 3
494   read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220@\0\0\0\0\0\0"..., 832) = 832
494   fstat(3, {st_mode=S_IFREG|0644, st_size=97176, ...}) = 0
494   mmap(NULL, 2202200, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fcee8968000
494   mprotect(0x7fcee897f000, 2093056, PROT_NONE) = 0
494   mmap(0x7fcee8b7e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7fcee8b7e000
494   mmap(0x7fcee8b80000, 6744, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fcee8b80000
494   close(3)                          = 0
494   access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
494   openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
494   read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P#\0\0\0\0\0\0"..., 832) = 832
494   fstat(3, {st_mode=S_IFREG|0644, st_size=47568, ...}) = 0
494   mmap(NULL, 2168632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fcee8756000
494   mprotect(0x7fcee8761000, 2093056, PROT_NONE) = 0
494   mmap(0x7fcee8960000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa000) = 0x7fcee8960000
494   mmap(0x7fcee8962000, 22328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fcee8962000
494   close(3)                          = 0
494   mprotect(0x7fcee8960000, 4096, PROT_READ) = 0
494   mprotect(0x7fcee8b7e000, 4096, PROT_READ) = 0
494   mprotect(0x7fcee8d8c000, 4096, PROT_READ) = 0
494   munmap(0x7fcee95a3000, 50970)     = 0
494   openat(AT_FDCWD, "/etc/ichangedthis", O_RDONLY|O_CLOEXEC) = 3
494   lseek(3, 0, SEEK_CUR)             = 0
494   fstat(3, {st_mode=S_IFREG|0644, st_size=1970, ...}) = 0
494   mmap(NULL, 1970, PROT_READ, MAP_SHARED, 3, 0) = 0x7fcee95af000
494   lseek(3, 1970, SEEK_SET)          = 1970
494   munmap(0x7fcee95af000, 1970)      = 0
494   close(3)                          = 0
494   ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
494   ioctl(0, TIOCGPTN, [1])           = 0
494   stat("/dev/pts/1", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
494   fcntl(0, F_GETFL)                 = 0x8802 (flags O_RDWR|O_NONBLOCK|O_LARGEFILE)
494   stat("/dev/pts/1", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
494   getuid()                          = 1001
494   access("/var/run/utmpx", F_OK)    = -1 ENOENT (No such file or directory)
494   openat(AT_FDCWD, "/var/run/utmp", O_RDONLY|O_CLOEXEC) = 3
494   lseek(3, 0, SEEK_SET)             = 0
494   access("/var/run/utmpx", F_OK)    = -1 ENOENT (No such file or directory)
494   openat(AT_FDCWD, "/var/run/utmp", O_RDWR|O_CLOEXEC) = -1 EACCES (Permission denied)
494   exit_group(1)                     = ?
494   +++ exited with 1 +++
32231 <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 494
32231 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=494, si_uid=1001, si_status=1, si_utime=0, si_stime=0} ---
32231 rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f8f459b6f20}, NULL, 8) = 0
32231 chmod("/dev/pts/1", 0666)         = 0
32231 chown("/dev/pts/1", 0, 0)         = -1 EPERM (Operation not permitted)
32231 close(5)                          = 0
32231 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=32232, si_uid=1001, si_status=SIGHUP, si_utime=0, si_stime=0} ---
32231 brk(0x55d24f041000)               = 0x55d24f041000
32231 geteuid()                         = 1001
32231 getegid()                         = 1001
32231 unlink("/run/screen/S-test/32231.pts-0.dev-machine") = 0
32231 geteuid()                         = 1001
32231 getegid()                         = 1001
32231 ioctl(-1, TCGETS, 0x7ffd944226d0) = -1 EBADF (Bad file descriptor)
32231 ioctl(-1, TCGETS, 0x7ffd944228a0) = -1 EBADF (Bad file descriptor)
32231 ioctl(-1, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = -1 EBADF (Bad file descriptor)
32231 openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 5
32231 fstat(5, {st_mode=S_IFREG|0644, st_size=2995, ...}) = 0
32231 read(5, "# Locale name alias data base.\n#"..., 4096) = 2995
32231 read(5, "", 4096)                 = 0
32231 close(5)                          = 0
32231 openat(AT_FDCWD, "/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 openat(AT_FDCWD, "/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
32231 fcntl(-1, F_SETFL, O_RDONLY)      = -1 EBADF (Bad file descriptor)
32231 kill(32230, SIGHUP)               = -1 ESRCH (No such process)
32231 exit_group(1)                     = ?
32231 +++ exited with 1 +++

相关内容