4

I've got a screen session running which I would like to :quit, but I can't because when I try to re-attach, I get an error saying it can't open my terminal. I'm sure I could kill the daemon or something, but I need to learn the "right" way, as well as what's actually going on.

 daniel@DELIRIUM:~/server1/bin/plugins$ screen -list
 There is a screen on:
        1424.pts-0.DELIRIUM     (06/23/2011 01:18:14 PM)        (Detached)
 1 Socket in /var/run/screen/S-daniel.

 daniel@DELIRIUM:~/server1/bin/plugins$ screen -r 1424
 Cannot open your terminal '/dev/pts/0' - please check.

Also, what is a socket? The more you can dumb it down the better.

6

You don't own your TTY for some reason. Did you use su to change to that user from another user? Normally the TTY is owned by the person who originally logs into that terminal.

There's a neat trick to fix this (other than changing the permissions on the /dev/pts/0 file by the user who originally logged in), the bsdutils package has a program called script which, when run, acts something like a keylogger, saving both what you type and what programs print. It starts another shell and allocates another pseudotty for that shell in order to record all this, so if you run script /dev/null it will create a new pseudotty with proper permissions, and start recording everything on it to /dev/null. Then you will be able to use screen to reattach your session.

As for "sockets", this is screen's term for the named pipe files (also known as FIFOs) in /var/run/screen/S-username, eg

prw------- 1 derf derf 0 Jun 23 22:42 30029.pts-0.server

When you first start screen, this pipe file is created in order to connect the screen process you are using to view the displays with the background screen process (usually renamed SCREEN) the programs are actually running in. When you run screen -r, the screen process you are running opens this pipe to talk to the background screen process.

| improve this answer | |
  • Thank you! I don't recall, I had a bunch of windows open and I am prone to doing silly things like switching to other users when I shouldn't. I'm going to make a note of your solution (future reference yay!) but the easier one was to log on to another tty with the correct user and close it :) Thanks for clarifying about sockets too! Little by little I'll wrap my head around linux. So much more complicated than administering a W2K3 server. – Daniel B. Jun 24 '11 at 4:50
1

Something weird is going on here. Can you please paste the output of :

   ls -l /dev/pts/0
   id

A socket in this case is a form of interprocess communication, its a file on the filesystem that forms a channel between the process and with... other processes. So your screen "client" is talking to the other running screen instance, and this is how the magic of screen works. Sockets are confusing concepts in Linux because traditionally people think of the word socket as meaning as Network Sockets. Its a hard concept to dumb down, it fits into a range of other inter-process communication channels best explained by the book "Advanced Programming in the UNIX Environment".

| improve this answer | |
  • You were on the right track and I appreciate it, and thank you for the sockets explanation. Makes me sad I can only accept one answer. – Daniel B. Jun 24 '11 at 4:52

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.