我有几个长时间运行的GNU屏幕会话。我将它们放在正在运行的盒子上,screen -d -r foo
如果它们已连接到其他任何地方,则将它们分离,然后将它们附加到当前窗口中。
99%的时间可以正常工作,但有时我会得到:
$ screen -d -r foo
[2430.foo detached.]
...什么也没有发生;我根本无法回到外壳。在另一个窗口中尝试做同样的事情,我唯一能做的就是销毁该屏幕会话(丢失正在其中运行的所有程序)并重新创建它
为什么会这样?发生这种情况时如何避免或成功重新连接?
编辑:我的.screenrc
:
startup_message off
defwritelock off
bind q quit
caption always '%{gk} (%n) %t %{y}%d %M %Y :: %c:%s %{b}%W%{d}'
screen -t ZSH
autodetach on
shelltitle ZSH
defutf8 on
编辑:strace
尝试附加时日志的结尾:
readlink("/proc/self/fd/0", "/dev/pts/14", 4095) = 11
stat64("/dev/pts/14", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 14), ...}) = 0
stat64("/dev/pts/14", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 14), ...}) = 0
geteuid32() = 1000
getegid32() = 1000
open("/dev/pts/14", O_RDWR|O_NONBLOCK) = 3
geteuid32() = 1000
getegid32() = 1000
close(3) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
umask(0) = 022
lstat64("/var/run/screen", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
access("/var/run/screen/S-mrozekma", F_OK) = 0
stat64("/var/run/screen/S-mrozekma", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
umask(022) = 0
uname({sys="Linux", node="etudes-2", ...}) = 0
rt_sigaction(SIGHUP, {0x806e520, [], 0}, {SIG_DFL, [], 0}, 8) = 0
geteuid32() = 1000
getegid32() = 1000
open("/var/run/screen/S-mrozekma", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
getdents(3, /* 6 entries */, 32768) = 124
stat64("/var/run/screen/S-mrozekma/2386.chat", {st_mode=S_IFIFO|0700, st_size=0, ...}) = 0
geteuid32() = 1000
getegid32() = 1000
open("/var/run/screen/S-mrozekma/2386.chat", O_WRONLY|O_NONBLOCK) = 4
geteuid32() = 1000
getegid32() = 1000
fcntl64(4, F_SETFL, O_RDONLY) = 0
geteuid32() = 1000
getegid32() = 1000
getdents(3, /* 0 entries */, 32768) = 0
close(3) = 0
geteuid32() = 1000
getegid32() = 1000
setuid32(1000) = 0
setgid32(1000) = 0
stat64("/var/run/screen/S-mrozekma/2386.chat", {st_mode=S_IFIFO|0700, st_size=0, ...}) = 0
getpid() = 30081
write(4, "\0gsm\4\0\0\0/dev/pts/14\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 12336
strace screen -d -r foo
(您可能需要制作screen
可执行文件的未设置副本),并strace -p$(pidof SCREEN)
在重新连接失败时进行发布。
strace
日志。strace
主屏幕进程显示了write()
通话中的类似内容
screen
试图写入不再存在的连接?
SCREEN
)仍然存在吗?它在做什么(strace
)?