Control multiple program instances - open multiple files problem
Hello. This shouldn't be an unusual problem, but I cannot find anything about it at google or at other search machine.
So, I've made an application using C++ and QtCreator. I 've made a new mime type for application's project files.
My system (ubuntu 10.10), when I right click a file and I choose "Open With 'Default Application'" the it runs
So, if you select multiple files and select "Open With 'Default Application'" the system will call
So, this is a big problem for me, because I handle the concurrent processes from inside the program, so when another instance of the program is running, a warning message is appeared. So, each application's call will recognize the others as currently running applications and so it'll show the message. I'll end up with 3 Messages saying that another process of the program is running --_--'
My application handles multiple URLs this way:
How can I make my code handle all these multiple instances at the same time? Everything I've tried fails, because everything I've tried requires a check from the first instance called, which is too slow and other instances come app and all together are warning about concurrent processes of the same program
So, how can I fix this? is it system depended, or can I do something with the code?
Well, you'll need a way to communicate with the original process when an extra one is run, so it can check if it's first and if not, just send a message to the first and quit.
Message queues might work. They're convenient in having a property that their names are global across the system.
Have the process try to create a message queue with mq_open("/username_myapp", O_RDONLY|O_CREAT, 0600, NULL). If it succeeds in creating the message queue, it knows it's the first one, and sets up a thread to receive messages on it with mq_receive() until the program quits. (Or you could use it in nonblocking mode and poll it.) Make sure to destroy the message queue with mq_unlink when you quit, or it will continue to exist even after all your programs have quit!
If it fails to create it on the other hand, just have it open it with mq_open("/username_myapp", O_WRONLY), send a message over it, and quit.
Hello,
I'm attempting to open multiple xterms and run a command as an SAP user via sudo using PSSH. So far, I'm able to run PSSH to a file of servers with no check for keys, open every xterm in to the servers in the file list, and SUDO to the SAP(ADM) user, but it won't do anything else... (11 Replies)
Hi,
I want to work with multiple files which all contain 2 numbers.
I tried to make a nested for loop but for some reason it doesn't recognize the $j as a number. The output is cannot open file `175-T-pvalue.xls'. How do I make sure that it takes the numbers from the inner loop as $j?
... (4 Replies)
Suppose I declare
pthread_t clear_thread;
and then
pthread_create(&clear_thread, &detach, clear_message, this);
the thread is supposed to go away, perform the service it is intended to procide, and then kill itself.
A little while later, I require this service again, so I say
... (2 Replies)
I have a question regarding Perl scripting.
If I want to say open files that all look like this and assign them to a filehandle and then assign the filehandle to a variable, how do I do this?
The file names are
strand1.fa.gz.tmp
strand2.fa.gz.tmp
strand3.fa.gz.tmp
strand4.fa.gz.tmp
...... (6 Replies)
Could you please let me know how to create/make a multiple instances of a job/process in ksh(shell scripting).
i.e., at present the parent script is calling another child/dependent script for only once.
What we want is, the parent script itself has to execute multiple times, and in each one it... (1 Reply)
Hi,
I know that the answer to this is very simple, since I saw somebody do it some time back..but I forgot how.
The problem is, I have multiple instances of the same program running simultaneously and I want to kill them all in a single command.
I know that it can be done using awk '{print... (12 Replies)
Hi Gurus
I have a requirement like this. i use solaris OS..
if there are 2 instances of the same ksh file running in the directory, i need to kill the ksh file that started to run latest.
suppose ragha.ksh starts running thru cron in abc/xyz directory
now ragha.ksh started running by any... (3 Replies)
I am capturing text based reports with a specific program, which works no problem. However, since I send report warehouse output as they are migrated from the database software, on occasion when two capture process' initiate simultaneously, the capture file locks up. Is there a way to setup (in... (1 Reply)
I would like to start up multiple instances of syslog daemon. I am having a little difficulty. Is this at all possible?
I have separate syslog.conf1.... syslog.conf5 files.
I have linked the daemon to separate files syslogd1 ... syslogd5
I have arranged the rcd.2 start/stop scripts for... (9 Replies)