IPC: Shared Files vs. Named Pipes

F

fahad.usman

I am making an application in which if the second instance of the same
application is launched, it checks its command-line arguments and
passes them to the already running instance. I have been told by
someone that using named pipes is one of the most commonly used ways
of doing this. But I did it in a simpler way; I saved the command-line
arguments in a text file and passed a message to the previously
running instance to read the arguments from that file. The second
instance then terminates and the first instance deletes the file after
reading the arguments from it. This technique is working perfectly
fine for me, but I was just wondering that are there any drawbacks in
this approach or am I going to get any advantage if I do it using
named pipes?

(I read on support.microsoft (http://support.microsoft.com/kb/q95900)
that shared files is one of the ways for IPC but i am not sure what i
am doing is actually that 'shared files')
 
A

ajk

I am making an application in which if the second instance of the same
application is launched, it checks its command-line arguments and
passes them to the already running instance. I have been told by
someone that using named pipes is one of the most commonly used ways
of doing this. But I did it in a simpler way; I saved the command-line
arguments in a text file and passed a message to the previously
running instance to read the arguments from that file. The second
instance then terminates and the first instance deletes the file after
reading the arguments from it. This technique is working perfectly
fine for me, but I was just wondering that are there any drawbacks in
this approach or am I going to get any advantage if I do it using
named pipes?

(I read on support.microsoft (http://support.microsoft.com/kb/q95900)
that shared files is one of the ways for IPC but i am not sure what i
am doing is actually that 'shared files')

Why don't you just pass the cmdline arguments with the message?
Stuffing everything into a string, marshaling it and then sending it
to the other process should be a simple matter. I think frankly using
named pipes or shared memory is overkill in your case.

I am not quite sure about what environment you run in like security
requirements etc however generally I don't think it is a good idea to
do as you have done. It is better to keep everything inside the app.

hth/ajk
 
B

Ben Voigt [C++ MVP]

I am making an application in which if the second instance of the same
application is launched, it checks its command-line arguments and
passes them to the already running instance. I have been told by
someone that using named pipes is one of the most commonly used ways
of doing this. But I did it in a simpler way; I saved the command-line
arguments in a text file and passed a message to the previously
running instance to read the arguments from that file. The second
instance then terminates and the first instance deletes the file after
reading the arguments from it. This technique is working perfectly
fine for me, but I was just wondering that are there any drawbacks in
this approach or am I going to get any advantage if I do it using
named pipes?

Well, what is the third instance going to do? Overwrite the file made by
the second instance?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top