User avatar
mad-hatter
Posts: 419
Joined: Sun Feb 26, 2012 2:58 pm
Location: By the UK seaside

C++/Qt4 Interprocess communications

Wed Sep 24, 2014 5:00 pm

C++/Qt4 Interprocess communications

Hello,

I've designed a program that is started with a command line argument "./myprog 1".
I would like to have more than 1 instance running but no new instance can have the same
argument as an already running instance.
ie. If "./myProg 1" is running, I'm not allowed to start a new "./myProg 1" but I would be
allowed to start "./myProg 2" or "./myProg 3", so I need some way of finding out which
instances with their arguments are already running.
My first thought was to write to a file that all instances of the program could read and write
to check each others status, but with people using SD cards, I would like to keep writes to a
minimum. I came across the shared memory option, but for me is fairly heavy going, although
with examples on the InterWeb I should be able to get it working.

Perhaps some forum readers could suggest other/easier ways to achieve this.

Regards

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: C++/Qt4 Interprocess communications

Wed Sep 24, 2014 9:15 pm

Look at Message Queues for a 'cheap' interprocess comm. Mosquitto is very easy to tailor to this scenario.

Return to “C/C++”