1

I was having difficulty reattaching to a screen session, so I tried to kill the client screen session and reattach to the server session. This failed. Then I did something kinda stupid. I did a -wipe. Now I have no named pipe file in the /tmp/uscreens/... directory.

The screen server is still running and I was wondering if it was somehow possible to recreate the named pipe.

I'm using Screen version 4.00.03 (FAU) 23-Oct-06 running under cygwin running under Win7 Home Premium. Though I could recover from killing the screen sever and it's children, I would prefer not to.

Any ideas?

EDIT: Here is the list from my fd dir:

$ ls -l /proc/8728/fd/
total 0
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 0 -> /dev/null
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 1 -> /dev/null
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 10 -> /dev/ptmx
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 11 -> /cygdrive/c/Users/Adrian/Downloads/arduino-1.0.3-windows/Projects/RangeDetector5/screenlog.2
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 2 -> /dev/null
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 3 -> /tmp/uscreens/S-Adrian/8728.pty0.TARDIS
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 4 -> /dev/pty0
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 5 -> /var/run/utmp
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 6 -> /dev/ptmx
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 7 -> /cygdrive/c/Users/Adrian/Downloads/arduino-1.0.3-windows/Projects/RangeDetector5/screenlog.0
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 8 -> /dev/ptmx
lrwxrwxrwx 1 Adrian None 0 May 12 22:32 9 -> /cygdrive/c/Users/Adrian/Downloads/arduino-1.0.3-windows/Projects/RangeDetector5/screenlog.1
2

The situation here:

start cmd: # ps -o pid,args -p 4629 --no-headings
4629 SCREEN
start cmd: # ls -l /proc/4629/fd | grep socket
lrwx------ 1 root root 64 13. Mai 02:55 4 -> socket:[90202]
start cmd: # lsof -n | grep 90202
screen     4629   [...]  90202 /var/run/screens/S-root/4629.pts-12.inno

I guess what you have deleted is the equivalent to my /var/run/screens/S-root/4629.pts-12.inno. ls -l /proc/$PID/fd may still point to the socket node. If you delete files then you can get their content via /proc/$PID/fd as long as a process keeps them opened. I am not familiar with sockets but you can at least give it a try: You can create a symlink (instead of the deleted socket) which points to the socket descriptor in /proc/$PID/fd.

Edit 1:

It may not be sufficient to set a symlink to a socket because the client process may check the type of file and find a symlik where it expects a socket and thus abort without checking the symlink target.

This problem can perhaps be solved with socat. This program allows a "socket forwarding". I have just tested it (with gpg-agent instead of screen though; and the original socket was not deleted):

start cmd:> echo $GPG_AGENT_INFO 
/tmp/gpg-DMOHGo/S.gpg-agent:3236:1
# next command in another shell
start cmd:> socat UNIX-LISTEN:gpg-agent-socket UNIX-CONNECT:/tmp/gpg-DMOHGo/S.gpg-agent
start cmd:> GPG_AGENT_INFO=/home/hl/tmp/gpg-agent-socket:3236:1
start cmd:> start cmd:> gpg-connect-agent 
> 

This may work with the socked FD in /proc, too. Furthermore socat supports FIFOs (named pipes).

Edit 2:

It does work with FIFOs, too:

socat PIPE:/proc/8728/fd/3 PIPE:/tmp/uscreens/S-Adrian/8728.pty0.TARDIS

should do.

BTW: Even if this does not solve your problem (yet) I do think that the effort and quality of my answer should at least be worth an upvote...

  • since I'm using cygwin, it doesn't quite map the same way. Nothing with -> socket:[...]. They all appear to be symlinks in the /proc/$PID/fd directory. – Adrian May 13 '13 at 2:34
  • How would I create a symlink? Using ln? Would it not be better for a hard link using cp -l? Also, cygwin doesn't have the lsof command. – Adrian May 13 '13 at 2:40
  • @Adrian You cannot hardlink across file systems and not within /proc at all. Symlinks are created with ln -s (or cp -s). – Hauke Laging May 13 '13 at 3:17
  • Looks like I can't copy. With the command: $ cp -s /proc/8728/fd/3 /tmp/uscreens/S-Adrian/8728.pty0.TARDIS I get an error: cp: cannot stat `/proc/8728/fd/3': No such file or directory. I'm thinking that the file handle isn't accessible? – Adrian May 13 '13 at 4:35
  • 1
    @Adrian Strange. It seems that not only your screen acts differently from mine but also your socat. The file must exist, wouldn't make sense otherwise... You could ask a new question here (linking this one), reduced to the socat problem. – Hauke Laging May 14 '13 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.