c++ - Detect whether there is a qws server running -


in order launch little qt app on embedded system, need reliable way find out whether qt qws server running.

otherwise i'd need supply -qwsoption app run server itself. there way of doing it?

here solution settled for:

the qws server uses socket talk clients. test existence of socket.

i test whether server has socked open in order avoid falling orphaned sockets left on after qws server crash. done using lsof (list open files) on socket. if server running, list not empty , lsof return true. if server not running, lsof return false.

on system socket located in /tmp/qtembedded-0/qtembedded-0

so here bash code:

qwssock=/tmp/qtembedded-0/qtembedded-0  if [ ! -s $qwssock ] ;     echo "no socket $qwssock"     qwsopt=-qws elif lsof $qwssock ;     echo "server running on $qwssock"     qwsopt= else     echo "no server on $qwssock"     qwsopt=-qws fi 

after can run qt app using $qwsopt variable:

app $qwsopt 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -