I have previously reattached to a long-running screen session with
screen -dr control. However, sometimes this command will not reattach to the screen and instead hang forever (10+ minutes after which I aborted). This only happens when the SSH connection is dropped unexpectedly and not when the screen is properly detached with
Ctrl-A d. Other switches, such as
screen -x or
screen -D -RR also do not work.
This post suggests to kill the PTY that holds the screen session which will cause screen to complete its disconnect. However, it simply kills the shell from which
screen -dr control was called.
$ ps -ef | grep control | grep -v grep nomad 7387 7109 0 13:05 pts/50 00:00:00 screen -dr control nomad 15299 1 0 Nov27 ? 00:13:47 SCREEN -S control $ ps -ef | grep bash | grep 'pts/50' nomad 7109 7108 0 12:49 pts/50 00:00:00 -bash
The linked post suggest to kill the
bash process with PID 7109. This will also kill the
screen -dr control process with PID 7387. Afterwards, I still cannot connect to the screen.
SCREEN -S control which started the screen session has
init as its parent which I obviously cannot kill.
Is there a way to reattach to the hung screen session?
Update: This happens on CentOS 6.4 using kernel 2.6.32-358.6.1.el6.x86_64. The shells are all bash version 4.1.2(1)-release.