Discussion:
[PATCH] Give descriptive message when no sessions present
(too old to reply)
Karthik K
2015-04-15 14:36:57 UTC
Permalink
When no sessions are present, "tmux ls" now displays an error
"Falied to connect: Connection Refused". This is confusing and creates
an impression that tmux is present but refusing connections.

The patch makes tmux display a message indicating that sessions may not be
present.

Karthik K (1):
Give descriptive message when no sessions present

client.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
--
2.3.5
Karthik K
2015-04-15 14:36:58 UTC
Permalink
---
client.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/client.c b/client.c
index 8e55640..ea53ca6 100644
--- a/client.c
+++ b/client.c
@@ -252,7 +252,7 @@ client_main(int argc, char **argv, int flags)
if (shell_cmd == NULL && environ_path != NULL &&
(cmdflags & CMD_CANTNEST) &&
strcmp(socket_path, environ_path) == 0) {
- fprintf(stderr, "sessions should be nested with care, "
+ fprintf(stderr, "Sessions should be nested with care, "
"unset $TMUX to force\n");
return (1);
}
@@ -260,8 +260,13 @@ client_main(int argc, char **argv, int flags)
/* Initialize the client socket and start the server. */
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
if (fd == -1) {
- fprintf(stderr, "failed to connect to server: %s\n",
- strerror(errno));
+ fprintf(stderr, "Failed to connect to tmux server: ");
+ if (errno == 111) { //Most probably no tmux session is present
+ fprintf (stderr, "No tmux sessions seem to be running\n");
+ }
+ else {
+ fprintf ("%s\n", strerror(errno));
+ }
return (1);
}
--
2.3.5
Nicholas Marriott
2015-04-15 14:44:42 UTC
Permalink
Hi

I think the current message is fine. We describe what is meant by
"server" in the first few paragraphs of the man page.
Post by Karthik K
---
client.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/client.c b/client.c
index 8e55640..ea53ca6 100644
--- a/client.c
+++ b/client.c
@@ -252,7 +252,7 @@ client_main(int argc, char **argv, int flags)
if (shell_cmd == NULL && environ_path != NULL &&
(cmdflags & CMD_CANTNEST) &&
strcmp(socket_path, environ_path) == 0) {
- fprintf(stderr, "sessions should be nested with care, "
+ fprintf(stderr, "Sessions should be nested with care, "
"unset $TMUX to force\n");
return (1);
}
@@ -260,8 +260,13 @@ client_main(int argc, char **argv, int flags)
/* Initialize the client socket and start the server. */
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
if (fd == -1) {
- fprintf(stderr, "failed to connect to server: %s\n",
- strerror(errno));
+ fprintf(stderr, "Failed to connect to tmux server: ");
+ if (errno == 111) { //Most probably no tmux session is present
+ fprintf (stderr, "No tmux sessions seem to be running\n");
+ }
+ else {
+ fprintf ("%s\n", strerror(errno));
+ }
return (1);
}
--
2.3.5
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Karthik K
2015-04-15 14:50:26 UTC
Permalink
Although the explanation for what a server is, is given in the man page,
the argument still holds. The error message just makes you think that there
is something wrong with the connection.

If it's not possible to patch the code, maybe atleast an entry can be added
at the end of the manpage detailing that "Connection Refused" most probably
means sessions are not present.
Post by Nicholas Marriott
Hi
I think the current message is fine. We describe what is meant by
"server" in the first few paragraphs of the man page.
Post by Karthik K
---
client.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/client.c b/client.c
index 8e55640..ea53ca6 100644
--- a/client.c
+++ b/client.c
@@ -252,7 +252,7 @@ client_main(int argc, char **argv, int flags)
if (shell_cmd == NULL && environ_path != NULL &&
(cmdflags & CMD_CANTNEST) &&
strcmp(socket_path, environ_path) == 0) {
- fprintf(stderr, "sessions should be nested with care, "
+ fprintf(stderr, "Sessions should be nested with care, "
"unset $TMUX to force\n");
return (1);
}
@@ -260,8 +260,13 @@ client_main(int argc, char **argv, int flags)
/* Initialize the client socket and start the server. */
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
if (fd == -1) {
- fprintf(stderr, "failed to connect to server: %s\n",
- strerror(errno));
+ fprintf(stderr, "Failed to connect to tmux server: ");
+ if (errno == 111) { //Most probably no tmux session is present
+ fprintf (stderr, "No tmux sessions seem to be running\n");
+ }
+ else {
+ fprintf ("%s\n", strerror(errno));
+ }
return (1);
}
--
2.3.5
------------------------------------------------------------------------------
Post by Karthik K
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live
exercises
Post by Karthik K
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
event?utm_
Post by Karthik K
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Thomas Adam
2015-04-15 14:55:03 UTC
Permalink
Although the explanation for what a server is, is given in the man page, the
argument still holds. The error message just makes you think that there is
something wrong with the connection.
Which is correct; no sessions means no server.

I really wouldn't go conflating ECONNREFUSED with "no sessions" when
there's any number of other reasons for that.

-- Thomas Adam
Nicholas Marriott
2015-04-15 15:03:15 UTC
Permalink
We could change it to something like "couldn't connect to server" or ask
"is the server running?" but I don't see much difference from "failed to
connect to server".

I don't think it is sensible to mention sessions, for tmux the server is
"the process that contains the sessions" by definition, we don't need to
say so explicitly.
Post by Karthik K
Although the explanation for what a server is, is given in the man page,
the argument still holds. The error message just makes you think that
there is something wrong with the connection.
If it's not possible to patch the code, maybe atleast an entry can be
added at the end of the manpage detailing that "Connection Refused" most
probably means sessions are not present.
On Apr 15, 2015 8:14 PM, "Nicholas Marriott"
Hi
I think the current message is fine.** We describe what is meant by
"server" in the first few paragraphs of the man page.
---
** client.c | 11 ++++++++---
** 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/client.c b/client.c
index 8e55640..ea53ca6 100644
--- a/client.c
+++ b/client.c
@@ -252,7 +252,7 @@ client_main(int argc, char **argv, int flags)
** ** ** **if (shell_cmd == NULL && environ_path != NULL &&
** ** ** ** ** **(cmdflags & CMD_CANTNEST) &&
** ** ** ** ** **strcmp(socket_path, environ_path) == 0) {
-** ** ** ** ** ** **fprintf(stderr, "sessions should be nested with
care, "
+** ** ** ** ** ** **fprintf(stderr, "Sessions should be nested with
care, "
** ** ** ** ** ** ** ** ** **"unset $TMUX to force\n");
** ** ** ** ** ** ** **return (1);
** ** ** **}
@@ -260,8 +260,13 @@ client_main(int argc, char **argv, int flags)
** ** ** **/* Initialize the client socket and start the server. */
** ** ** **fd = client_connect(socket_path, cmdflags &
CMD_STARTSERVER);
** ** ** **if (fd == -1) {
%s\n",
-** ** ** ** ** ** ** ** **strerror(errno));
+** ** ** ** ** ** **fprintf(stderr, "Failed to connect to tmux
server: ");
+** ** ** ** if (errno == 111) { //Most probably no tmux session is
present
+** ** ** ** ** ** fprintf (stderr, "No tmux sessions seem to be
running\n");
+** ** ** ** }
+** ** ** ** else {
+** ** ** ** ** ** fprintf ("%s\n", strerror(errno));
+** ** ** ** }
** ** ** ** ** ** ** **return (1);
** ** ** **}
--
2.3.5
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live
exercises
[2]http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
tmux-users mailing list
[4]https://lists.sourceforge.net/lists/listinfo/tmux-users
References
Visible links
2. http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
4. https://lists.sourceforge.net/lists/listinfo/tmux-users
Karthik K
2015-04-15 15:17:05 UTC
Permalink
Hmm.. Your arguments do hold merit. It's just that everyone I know have
been stumped by this message when they start using tmux. Just felt that the
error message should be more descriptive explaining the most common reason
for connection being refused.
Post by Nicholas Marriott
We could change it to something like "couldn't connect to server" or ask
"is the server running?" but I don't see much difference from "failed to
connect to server".
I don't think it is sensible to mention sessions, for tmux the server is
"the process that contains the sessions" by definition, we don't need to
say so explicitly.
Post by Karthik K
Although the explanation for what a server is, is given in the man
page,
Post by Karthik K
the argument still holds. The error message just makes you think that
there is something wrong with the connection.
If it's not possible to patch the code, maybe atleast an entry can be
added at the end of the manpage detailing that "Connection Refused"
most
Post by Karthik K
probably means sessions are not present.
On Apr 15, 2015 8:14 PM, "Nicholas Marriott"
Hi
I think the current message is fine.** We describe what is meant by
"server" in the first few paragraphs of the man page.
---
** client.c | 11 ++++++++---
** 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/client.c b/client.c
index 8e55640..ea53ca6 100644
--- a/client.c
+++ b/client.c
@@ -252,7 +252,7 @@ client_main(int argc, char **argv, int flags)
** ** ** **if (shell_cmd == NULL && environ_path != NULL &&
** ** ** ** ** **(cmdflags & CMD_CANTNEST) &&
** ** ** ** ** **strcmp(socket_path, environ_path) == 0) {
-** ** ** ** ** ** **fprintf(stderr, "sessions should be nested
with
Post by Karthik K
care, "
+** ** ** ** ** ** **fprintf(stderr, "Sessions should be nested
with
Post by Karthik K
care, "
** ** ** ** ** ** ** ** ** **"unset $TMUX to force\n");
** ** ** ** ** ** ** **return (1);
** ** ** **}
@@ -260,8 +260,13 @@ client_main(int argc, char **argv, int flags)
** ** ** **/* Initialize the client socket and start the server. */
** ** ** **fd = client_connect(socket_path, cmdflags &
CMD_STARTSERVER);
** ** ** **if (fd == -1) {
%s\n",
-** ** ** ** ** ** ** ** **strerror(errno));
+** ** ** ** ** ** **fprintf(stderr, "Failed to connect to tmux
server: ");
+** ** ** ** if (errno == 111) { //Most probably no tmux session
is
Post by Karthik K
present
+** ** ** ** ** ** fprintf (stderr, "No tmux sessions seem to be
running\n");
+** ** ** ** }
+** ** ** ** else {
+** ** ** ** ** ** fprintf ("%s\n", strerror(errno));
+** ** ** ** }
** ** ** ** ** ** ** **return (1);
** ** ** **}
--
2.3.5
------------------------------------------------------------------------------
Post by Karthik K
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live
exercises
[2]
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
Post by Karthik K
event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
Post by Karthik K
_______________________________________________
tmux-users mailing list
[4]https://lists.sourceforge.net/lists/listinfo/tmux-users
References
Visible links
2. http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
4. https://lists.sourceforge.net/lists/listinfo/tmux-users
Nicholas Marriott
2015-04-15 15:32:42 UTC
Permalink
I think we should change it to just "no server running" or something, it
better matches the "no sessions" that you get if you try "tmux attach":

diff --git a/client.c b/client.c
index 042ec92..e8d2b25 100644
--- a/client.c
+++ b/client.c
@@ -261,8 +261,12 @@ client_main(int argc, char **argv, int flags)
/* Initialize the client socket and start the server. */
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
if (fd == -1) {
- fprintf(stderr, "failed to connect to server: %s\n",
- strerror(errno));
+ if (errno == ECONNREFUSED)
+ fprintf(stderr, "no server running\n");
+ else {
+ fprintf(stderr, "couldn't connect to server (%s)\n",
+ strerror(errno));
+ }
return (1);
}
Post by Karthik K
Hmm.. Your arguments do hold merit. It's just that everyone I know have
been stumped by this message when they start using tmux. Just felt that
the error message should be more descriptive explaining the most common
reason for connection being refused.
On Apr 15, 2015 8:33 PM, "Nicholas Marriott"
We could change it to something like "couldn't connect to server" or ask
"is the server running?" but I don't see much difference from "failed to
connect to server".
I don't think it is sensible to mention sessions, for tmux the server is
"the process that contains the sessions" by definition, we don't need to
say so explicitly.
** ** Although the explanation for what a server is, is given in the
man page,
** ** the argument still holds. The error message just makes you think
that
** ** there is something wrong with the connection.
** ** If it's not possible to patch the code, maybe atleast an entry
can be
** ** added at the end of the manpage detailing that "Connection
Refused" most
** ** probably means sessions are not present.
** ** On Apr 15, 2015 8:14 PM, "Nicholas Marriott"
** ** ** Hi
** ** ** I think the current message is fine.** We describe what is
meant by
** ** ** "server" in the first few paragraphs of the man page.
** ** ** > ---
** ** ** >** client.c | 11 ++++++++---
** ** ** >** 1 file changed, 8 insertions(+), 3 deletions(-)
** ** ** >
** ** ** > diff --git a/client.c b/client.c
** ** ** > index 8e55640..ea53ca6 100644
** ** ** > --- a/client.c
** ** ** > +++ b/client.c
flags)
** ** ** >** ** ** **if (shell_cmd == NULL && environ_path != NULL &&
** ** ** >** ** ** ** ** **(cmdflags & CMD_CANTNEST) &&
** ** ** >** ** ** ** ** **strcmp(socket_path, environ_path) == 0) {
** ** ** > -** ** ** ** ** ** **fprintf(stderr, "sessions should be
nested with
** ** ** care, "
** ** ** > +** ** ** ** ** ** **fprintf(stderr, "Sessions should be
nested with
** ** ** care, "
** ** ** >** ** ** ** ** ** ** ** ** **"unset $TMUX to force\n");
** ** ** >** ** ** ** ** ** ** **return (1);
** ** ** >** ** ** **}
flags)
** ** ** >** ** ** **/* Initialize the client socket and start the
server. */
** ** ** >** ** ** **fd = client_connect(socket_path, cmdflags &
** ** ** CMD_STARTSERVER);
** ** ** >** ** ** **if (fd == -1) {
** ** ** > -** ** ** ** ** ** **fprintf(stderr, "failed to connect to
** ** ** %s\n",
** ** ** > -** ** ** ** ** ** ** ** **strerror(errno));
** ** ** > +** ** ** ** ** ** **fprintf(stderr, "Failed to connect to
tmux
** ** ** server: ");
** ** ** > +** ** ** ** if (errno == 111) { //Most probably no tmux
session is
** ** ** present
** ** ** > +** ** ** ** ** ** fprintf (stderr, "No tmux sessions seem
to be
** ** ** running\n");
** ** ** > +** ** ** ** }
** ** ** > +** ** ** ** else {
** ** ** > +** ** ** ** ** ** fprintf ("%s\n", strerror(errno));
** ** ** > +** ** ** ** }
** ** ** >** ** ** ** ** ** ** **return (1);
** ** ** >** ** ** **}
** ** ** >
** ** ** > --
** ** ** > 2.3.5
** ** ** >
** ** ** >
** ** ** >
** ** **
------------------------------------------------------------------------------
** ** ** > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
** ** ** > Develop your own process in accordance with the BPMN 2
standard
** ** ** > Learn Process modeling best practices with Bonita BPM
through live
** ** ** exercises
** ** ** >
[2][3]http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
** ** ** event?utm_
** ** ** >
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
** ** ** > _______________________________________________
** ** ** > tmux-users mailing list
** ** ** >
[4][5]https://lists.sourceforge.net/lists/listinfo/tmux-users
References
** ** Visible links
** ** 2.
[7]http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
** ** 4. [9]https://lists.sourceforge.net/lists/listinfo/tmux-users
References
Visible links
3. http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
5. https://lists.sourceforge.net/lists/listinfo/tmux-users
7. http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
9. https://lists.sourceforge.net/lists/listinfo/tmux-users
Nicholas Marriott
2015-04-21 22:22:16 UTC
Permalink
I've tweaked the errors slightly anyway to hopefully make them a bit
simpler. thanks
Post by Karthik K
Hmm.. Your arguments do hold merit. It's just that everyone I know have
been stumped by this message when they start using tmux. Just felt that
the error message should be more descriptive explaining the most common
reason for connection being refused.
On Apr 15, 2015 8:33 PM, "Nicholas Marriott"
We could change it to something like "couldn't connect to server" or ask
"is the server running?" but I don't see much difference from "failed to
connect to server".
I don't think it is sensible to mention sessions, for tmux the server is
"the process that contains the sessions" by definition, we don't need to
say so explicitly.
** ** Although the explanation for what a server is, is given in the
man page,
** ** the argument still holds. The error message just makes you think
that
** ** there is something wrong with the connection.
** ** If it's not possible to patch the code, maybe atleast an entry
can be
** ** added at the end of the manpage detailing that "Connection
Refused" most
** ** probably means sessions are not present.
** ** On Apr 15, 2015 8:14 PM, "Nicholas Marriott"
** ** ** Hi
** ** ** I think the current message is fine.** We describe what is
meant by
** ** ** "server" in the first few paragraphs of the man page.
** ** ** > ---
** ** ** >** client.c | 11 ++++++++---
** ** ** >** 1 file changed, 8 insertions(+), 3 deletions(-)
** ** ** >
** ** ** > diff --git a/client.c b/client.c
** ** ** > index 8e55640..ea53ca6 100644
** ** ** > --- a/client.c
** ** ** > +++ b/client.c
flags)
** ** ** >** ** ** **if (shell_cmd == NULL && environ_path != NULL &&
** ** ** >** ** ** ** ** **(cmdflags & CMD_CANTNEST) &&
** ** ** >** ** ** ** ** **strcmp(socket_path, environ_path) == 0) {
** ** ** > -** ** ** ** ** ** **fprintf(stderr, "sessions should be
nested with
** ** ** care, "
** ** ** > +** ** ** ** ** ** **fprintf(stderr, "Sessions should be
nested with
** ** ** care, "
** ** ** >** ** ** ** ** ** ** ** ** **"unset $TMUX to force\n");
** ** ** >** ** ** ** ** ** ** **return (1);
** ** ** >** ** ** **}
flags)
** ** ** >** ** ** **/* Initialize the client socket and start the
server. */
** ** ** >** ** ** **fd = client_connect(socket_path, cmdflags &
** ** ** CMD_STARTSERVER);
** ** ** >** ** ** **if (fd == -1) {
** ** ** > -** ** ** ** ** ** **fprintf(stderr, "failed to connect to
** ** ** %s\n",
** ** ** > -** ** ** ** ** ** ** ** **strerror(errno));
** ** ** > +** ** ** ** ** ** **fprintf(stderr, "Failed to connect to
tmux
** ** ** server: ");
** ** ** > +** ** ** ** if (errno == 111) { //Most probably no tmux
session is
** ** ** present
** ** ** > +** ** ** ** ** ** fprintf (stderr, "No tmux sessions seem
to be
** ** ** running\n");
** ** ** > +** ** ** ** }
** ** ** > +** ** ** ** else {
** ** ** > +** ** ** ** ** ** fprintf ("%s\n", strerror(errno));
** ** ** > +** ** ** ** }
** ** ** >** ** ** ** ** ** ** **return (1);
** ** ** >** ** ** **}
** ** ** >
** ** ** > --
** ** ** > 2.3.5
** ** ** >
** ** ** >
** ** ** >
** ** **
------------------------------------------------------------------------------
** ** ** > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
** ** ** > Develop your own process in accordance with the BPMN 2
standard
** ** ** > Learn Process modeling best practices with Bonita BPM
through live
** ** ** exercises
** ** ** >
[2][3]http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
** ** ** event?utm_
** ** ** >
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
** ** ** > _______________________________________________
** ** ** > tmux-users mailing list
** ** ** >
[4][5]https://lists.sourceforge.net/lists/listinfo/tmux-users
References
** ** Visible links
** ** 2.
[7]http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
** ** 4. [9]https://lists.sourceforge.net/lists/listinfo/tmux-users
References
Visible links
3. http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
5. https://lists.sourceforge.net/lists/listinfo/tmux-users
7. http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
9. https://lists.sourceforge.net/lists/listinfo/tmux-users
Loading...