Screen
verifica o fifo / socket sempre que recebe um sinal SIGCHLD
. Se o soquete estiver faltando, ele será recriado. Portanto, a solução é localizar o processo e enviá-lo SIGCHLD
.
No meu sistema Debian, screen
parece estar instalado como setgid utmp
mas não setuid, então a primeira solução das FAQ abaixo funcionou:
$ kill -CHLD 30860
$ ls /var/run/screen/S-username/
30860.pts-4.localhost
Em sistemas nos quais a tela está instalada setuid root
, isso não funcionará, e você precisará matar um dos processos filhos da sessão de tela ativa para forçar o kernel a enviar o sinal para você. Isso significa sacrificar uma das janelas da sua tela para se reconectar com o resto (escolha sabiamente!).
De um FAQ do Gentoo Wiki arquivado :
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.