Re: Any difference between `screen -r` vs `screen -x` when attaching to an already attached session?

Clark Wang <[email protected]>
Newsgroups gmane.comp.gnu.screen.user
Message-ID <CADv8-ogsLRvsrruJtdXm-U=cMjNhFasvZa+j9ikXr9u1HvdW4A@mail.gmail.com>
On Tue, Jul 5, 2016 at 7:17 AM, Dun Peal <[email protected]> wrote:

> Thanks, Andrew.
>
> My question is: specifically when attaching to a detached session, is
> there any difference between using `screen -r` and `screen -x`?
>
> For example, suppose I have a detached session called "foo", which I want
> to attach to. Is there any reason to prefer:
>
> screen -r foo
>
> To:
>
> screen -x foo
>
> The reason I'm asking is because I'm writing a script to attach to a
> screen session by name, and I was wondering if it's worth checking if the
> session is attached and using screen -r in that case, because if there's no
> difference, I'd just use screen -x, since it attaches to the session
> whether it's detached or not.
>

For a detached session I think `screen -r' and `screen -x' are doing the
same thing. But as Andrew pointed out `screen -x' is designed for multi
display mode so it's a bit weird to attach to a detached session using
`screen -x'. So for you `screen -r' is fine. If you are not sure if the
session is detached or not then you can `screen -dr' (first make it detach
then attach to it).


>
> Hope my question is clear... D.
>
> On Mon, Jul 4, 2016 at 6:23 PM, Andrew Savchenko <[email protected]>
> wrote:
>
>> Hi,
>>
>> On Mon, 4 Jul 2016 18:15:50 -0400 Dun Peal wrote:
>> > Looking for a command that would attach to a screen session "foo",
>> wether
>> > it is detached or not. It seems like `screen -x foo` would do it - it
>> > attaches to "foo" in both cases.
>> >
>> > But is it really the same?  Or is there any difference between `screen
>> -x
>> > foo` and `screen -r foo` when "foo" is detached?
>> >
>> > Specifically, is there a reason to choose one over the other when "foo"
>> is
>> > detached?
>>
>> -x option is needed for multiple display mode, when several users
>> work the same screen (very useful when one needs to educate
>> someone :)), so -x doesn't detach session if it is attached.
>>
>> -r is usually used in single user mode if session is already
>> detached. It can't attach to already attached session.
>>
>> Best regards,
>> Andrew Savchenko
>>
>> _______________________________________________
>> screen-users mailing list
>> screen-users-mXXj517/[email protected]
>> https://lists.gnu.org/mailman/listinfo/screen-users
>>
>>
>
> _______________________________________________
> screen-users mailing list
> screen-users-mXXj517/[email protected]
> https://lists.gnu.org/mailman/listinfo/screen-users
>
>

_______________________________________________
screen-users mailing list
screen-users-mXXj517/[email protected]
https://lists.gnu.org/mailman/listinfo/screen-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.