How do I reconnect to a lost screen (detached, missing socket)?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Isolated
--
Chapters
00:00 How Do I Reconnect To A Lost Screen (Detached, Missing Socket)?
00:48 Accepted Answer Score 29
03:04 Thank you
--
Full question
https://superuser.com/questions/58525/ho...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #gnuscreen
#avk47
ACCEPTED ANSWER
Score 29
Screen
checks the fifo/socket whenever it receives a SIGCHLD
signal. If the socket is missing, it will be recreated. So the solution is to find the process and send it SIGCHLD
.
On my Debian system, screen
appears to be installed as setgid utmp
but not setuid, so the first solution from the FAQ below worked:
$ kill -CHLD 30860
$ ls /var/run/screen/S-username/
30860.pts-4.localhost
On systems where screen is installed setuid root
, this won't work, and you'll need to kill one of the child processes of the active screen session to force the kernel to send the signal for you. This means sacrificing one of your screen windows to reconnect with the rest (choose wisely!).
From an archived Gentoo Wiki FAQ:
Socket Missing
Sometimes the socket of a still-running screen can be destroyed, though the actual process and all of its child processes are still running. screen -list will display "No Sockets found in /tmp/uscreens/.." Some handy instructions for how to recover from this (and a few other uncommon problems) at http://www4.informatik.uni-erlangen.de/~jnweiger/screen-faq.html#MISC about 2/3 of the way down.
Q: For some unknown reason, the fifo in /tmp/screens/S-myname is gone, and I can't resume my screen session. Is there a way to recreate the fifo?
A: Screen checks the fifo/socket whenever it receives a SIGCHLD signal. If missing, the fifo/socket is recreated then.
If screen is running non set-uid the user can issue a
kill -CHLD screenpid
directly (it is-CHILD
on some systems). Screenpid is the process-id of the screen process found in aps -x
listing.But usually this won't work, as screen should be installed setuid root. In this case you will not be able to send it a signal, but the kernel will. It does so, whenever a child of screen changes its state. Find the process-id (shellpid below) of the "least important" shell running inside screen. The try
kill -STOP shellpid
. If the fifo/socket does not reappear, destroy the shell process. You sacrify one shell to save the rest. If nothing works, please do not forget to remove all processes running in the lost screen session.