In order to properly launch a little Qt app on an embedded system, I need a reliable way to find out whether a Qt QWS server is already running.
Otherwise I'd need to supply the -qwsoption to the app to run the server itself. Is there a way of doing it?
Here is the solution I settled for:
The QWS server uses to socket to talk to its clients. I test for the existence of this socket.
I also test whether the server actually has the socked open in order to avoid falling for orphaned sockets left over after a QWS server crash. This is done using
lsof(list open files) on the socket. If the server is running, the list will not be empty andlsofwill returntrue. If the server is not running,lsofwill returnfalse.On my system the socket was located in
/tmp/qtembedded-0/QtEmbedded-0So here is the bash code:
After this I can run my Qt app using the
$QWSOPTvariable: