Patchwork [1,of,2] chg: server exited with code 0 without being connectable is an error

login
register
mail settings
Submitter Jun Wu
Date April 10, 2016, 11:56 p.m.
Message ID <20ad199286a5f70d46ac.1460332618@x1c>
Download mbox | patch
Permalink /patch/14498/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - April 10, 2016, 11:56 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1460322034 -3600
#      Sun Apr 10 22:00:34 2016 +0100
# Node ID 20ad199286a5f70d46ac4818dfa681327385d5a3
# Parent  99a2bdad0fda4fe16830376ad81c1065a5080cb9
chg: server exited with code 0 without being connectable is an error

Before this patch, if the server started by chg has exited with code 0 without
creating a connectable unix domain socket at the specified address, chg will
exit with code 0, which is not the correct behavior. It can happen, for
example, CHGHG is set to /bin/true.

This patch addresses the issue by checking the exit code of the server and
print a new error message if the server exited normally but cannot be
connected.
timeless - April 11, 2016, 3:29 a.m.
Jun Wu wrote:
> This patch addresses the issue by checking the exit code of the server and
> print a new error message if the server exited normally but cannot be
> connected.

print=>printing
connected=>contacted|reached
timeless - April 11, 2016, 3:30 a.m.
Which of course means I don't like the error message in the abort.
"Could not connect to cmdserver even though it exited without a failure code" ??

On Sun, Apr 10, 2016 at 11:29 PM, timeless <timeless@gmail.com> wrote:
> Jun Wu wrote:
>> This patch addresses the issue by checking the exit code of the server and
>> print a new error message if the server exited normally but cannot be
>> connected.
>
> print=>printing
> connected=>contacted|reached
Yuya Nishihara - April 11, 2016, 12:13 p.m.
On Sun, 10 Apr 2016 23:30:47 -0400, timeless wrote:
> Which of course means I don't like the error message in the abort.
> "Could not connect to cmdserver even though it exited without a failure code" ??

Hmm, how about "could not connect to cmdserver (exited with status 0)" ?

If cmdserver exits, it must be an error. So "even though" doesn't make sense
to me.
timeless - April 11, 2016, 3:59 p.m.
Yuya Nishihara wrote:
> On Sun, 10 Apr 2016 23:30:47 -0400, timeless wrote:
>> Which of course means I don't like the error message in the abort.
>> "Could not connect to cmdserver even though it exited without a failure code" ??
>
> Hmm, how about "could not connect to cmdserver (exited with status 0)" ?

Maybe. The question to me as a user is "what does it mean to exit with
a status of 0?" "is that a good thing. is that a bad thing?"

> If cmdserver exits, it must be an error. So "even though" doesn't make sense
> to me.

I agree
Yuya Nishihara - April 12, 2016, 1:59 p.m.
On Mon, 11 Apr 2016 11:59:16 -0400, timeless wrote:
> Yuya Nishihara wrote:
> > On Sun, 10 Apr 2016 23:30:47 -0400, timeless wrote:  
> >> Which of course means I don't like the error message in the abort.
> >> "Could not connect to cmdserver even though it exited without a failure code" ??  
> >
> > Hmm, how about "could not connect to cmdserver (exited with status 0)" ?  
> 
> Maybe.

Ok, queued with this message, thanks.

> The question to me as a user is "what does it mean to exit with
> a status of 0?" "is that a good thing. is that a bad thing?"

I think it's a kind of diagnostic information for developers.

Patch

diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -261,6 +261,9 @@ 
 
 cleanup:
 	if (WIFEXITED(pst)) {
+		if (WEXITSTATUS(pst) == 0)
+			abortmsg("cmdserver exited normally "
+				 "but cannot be connected");
 		debugmsg("cmdserver exited with status %d", WEXITSTATUS(pst));
 		exit(WEXITSTATUS(pst));
 	} else if (WIFSIGNALED(pst)) {