xpra icon
Bug tracker and wiki

Opened 5 weeks ago

Closed 5 weeks ago

Last modified 5 weeks ago

#1917 closed defect (wontfix)

incorrect exit code on "xpra stop" when server is not running

Reported by: onlyjob Owned by: Antoine Martin
Priority: trivial Milestone: 2.4
Component: server Version: 2.3.x
Keywords: Cc:

Description

xpra stop :314" exits with code 1` and the following error when server is not running:

  xpra initialization error:
 cannot find live server for display :314

Normal convention for init scripts is to exit with code 0 when there is nothing to do. It is not an error to stop (already stopped) non-running server when desirable condition is already fulfilled.
If server is not running then exit code should be 0 (already stopped).

Change History (4)

comment:1 Changed 5 weeks ago by onlyjob

Component: androidserver
Priority: majortrivial

comment:2 Changed 5 weeks ago by Antoine Martin

Milestone: 2.4
Resolution: wontfix
Status: newclosed

No, all client commands, be it "attach", "info", "stop" or others will only return 0 when they have carried out the operation requested.
If the server does not exist, the stop request has not succeeded.

comment:3 Changed 5 weeks ago by onlyjob

Fair enough, I understand it is a historical behaviour but it would be better
for two "stop" commands to return 0 both times even if only first command "carried out the operation requested".

Only end result matters. If stop is requested then meaningful exit code indicates _desirable state_ rather than carried action. If we failed to stop and the server is still running - only then meaningful exit code is non-zero.

Maybe it could be fixed in future releases?

Correct exit codes are also useful for CI testing. As a matter of fact that's where I've noticed the problem...

comment:4 Changed 5 weeks ago by Antoine Martin

Fair enough, I understand it is a historical behaviour

It isn't "historical behaviour", just correct.

Only end result matters. If stop is requested then meaningful exit code indicates _desirable state_ rather than carried action. If we failed to stop and the server is still running - only then meaningful exit code is non-zero.

And since a socket not found in no way indicates that the server is not running, returning zero is totally the wrong thing to do. This would introduce race conditions where none exist at present. (ie: slow server start would show up as stopped when in fact it hasn't finished starting)

Maybe it could be fixed in future releases?

There is nothing to fix here, your scripts perhaps.

If you want to check that a server exists and is running, try xpra version $THEDISPLAY. IFF this returns zero, xpra stop $THEDISPLAY must return zero. A non zero error code in this case indicates an error.

Note: See TracTickets for help on using tickets.