Apr 171999
 

screen – how to remove “remote or dead” sessions

This article shows you what I did to remove some dead screen sessions.

What is screen?

screen allows you to detach a session from your console or telnet session and resume it at a later time.  It’s great for dial up users who need to disconnect and reconnect but not lose their work in progress.

The problem

The following outlines the problem I am trying to solve.
# screen -list
There are screens on:
        59963.rc5       (Detached)
        53764.mail      (Remote or dead)
        23079.cool      (Detached)
        12476.top1      (Remote or dead)
4 Sockets in /tmp/screens/S-chris.

If I try to resume either of the two sessions marked as remote or dead, I get the following message:

# screen -r mail
There is a screen on:
        53764.mail      (Dead ???)
Remove dead screens with 'screen -wipe'.
There is no screen to be resumed matching mail.

If I try screen -r 53764.mail, I get the same response.

Attempts to use wipe don’t seem to do anything:

$ screen -wipe mail
There are screens on:
        59963.rc5       (Detached)
        53764.mail      (Remote or dead)
        23079.cool      (Detached)
        12476.top1      (Remote or dead)
4 Sockets in /tmp/screens/S-chris.

The solution

If you can’t remove the sessions using the above attempts, then perhaps the process associated with the screen is dead.  Using ps to see if the process is still alive shows that the process is indeed dead.  Each screen must have a corresponding process with the same id as the first component of the screen name.
# ps -auxw | grep 53764
mike 78094 0.0  0.9   276  112  p0  R+    5:04PM   0:00.19 grep 53764
[mike@ns:/usr/local/etc/rc.d] $ 

Looking at that, there is no process with the ID in question (53764).   See the previous section for the location of this value within the screen listing output.

I’m just going to delete the files in question and see what happens.

# cd /tmp/screens/S-chris
# ls -lt
total 0
srw-------  1 chris  chris  0 Apr 14 13:54 23079.cool
srw-------  1 chris  chris  0 Apr 12 09:16 59963.rc5
srw-------  1 chris  chris  0 Mar 22 13:19 53764.mail
srwx------  1 chris  chris  0 Mar  8 21:09 12476.top1
# rm 53764.mail

Now I get this listed:

screen -list
There are screens on:
        59963.rc5       (Detached)
        23079.cool      (Detached)
        12476.top1      (Remote or dead)
3 Sockets in /tmp/screens/S-chris.

So far so good.  I did the same with the other dead file.