Xpra: Ticket #1917: incorrect exit code on "xpra stop" when server is not running

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).



Mon, 16 Jul 2018 03:24:40 GMT - onlyjob: priority, component changed


Mon, 16 Jul 2018 08:10:15 GMT - Antoine Martin: status changed; resolution, milestone set

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.


Mon, 16 Jul 2018 12:27:56 GMT - 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...


Tue, 17 Jul 2018 08:59:20 GMT - 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.


Sat, 23 Jan 2021 05:37:14 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1917