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).
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.
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...
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.
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1917