Solved

Signalling different processes

Posted on 1998-06-23
15
217 Views
Last Modified: 2013-11-20
Can i  use the process-id of a process to send a signal from another process using the process-id? If this is not possible can u please suggest one way of sending signals to different processes?
0
Comment
Question by:akhila
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1318313
No. You can either send window messages if there are windows or use the synchronization objects, such as event objects.
0
 

Author Comment

by:akhila
ID: 1318314
Can u please give me the code segment of 2 separate applications trying to synchronize using the CEvent object? I am not able to understand where the actual connection between the 2 applications is created and how.
Thank U

0
 
LVL 23

Expert Comment

by:chensu
ID: 1318315
Look into the MFC Sample MTGDI. It is a multithread program. Two threads are similar to two applications except that you should give the event object a name so that another application can refer to it.

CEvent( BOOL bInitiallyOwn = FALSE, BOOL bManualReset = FALSE, LPCTSTR lpszName = NULL, LPSECURITY_ATTRIBUTES lpsaAttribute = NULL );

lpszName   Name of the CEvent object. Must be supplied if the object will be used across process boundaries. If the name matches an existing event, the constructor builds a new CEvent object which references the event of that name. If the name matches an existing synchronization object that is not an event, the construction will fail. If NULL, the name will be null.

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:akhila
ID: 1318316
U have given the same text from the book!! Now one thing still i am not able to understand is that from which appliction I will be calling the CEvent constructor? SHould I have it both the applns. with the same name  or how should I proceed? I am notr able to understand from that example.

0
 
LVL 23

Expert Comment

by:chensu
ID: 1318317
You should construct the CEvent objects in both the applications with the same name. When it is constructed in this way, a new event object will be created if the name does not exist yet. Otherwise, if the name exists due to one of the applications has created it, the event object will reference the event of that name.
0
 

Author Comment

by:akhila
ID: 1318318
Sorry for disturbing u again!! If u dont mind please can u give a simple code construct of 2 applications using and accessing CEvent?
Thank U very much

0
 
LVL 23

Expert Comment

by:chensu
ID: 1318319
I am sorry that I don't have enough time to write it.
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1318320
akhila,

A little friendly advice. I think you're being a little unrealistic in offering 10 points and expecting verbose, in depth answers. I think (considering the points) chensu has given very good advice in answering your question.

Don't get me wrong. we all frequently answer "low rent" questions(20-50 points). However, most developers don't have the time or motivation to write someone else's code when the person requesting the help thinks the help merits so little.

Just my 0.02,
Tom

0
 

Author Comment

by:akhila
ID: 1318321
Tma,
   Ok..I have increased the points to 100. Can you help atleast now?
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1318322
I sincerely hope that you don't feel upset about my remarks. My only intention was to aid you in getting your question answered to your satisfaction. Since you have waited for an answer for about 3 weeks, I made the suggestion of upping the points in order to encourage more responses.

Having said that, honor dictates that I should give chensu first crack at this since you were working with him. If he passes, then I'll throw together a simple example for you. Ok?

Tom

0
 

Author Comment

by:akhila
ID: 1318323
Thank U tom.

0
 
LVL 23

Expert Comment

by:chensu
ID: 1318324
Hi tma,

Your turn.

akhila,

Don't misunderstand. I don't have enough time. If I had a ready example, I would have provided.
0
 

Author Comment

by:akhila
ID: 1318325
Thank U Chensu
0
 
LVL 2

Accepted Solution

by:
duneram earned 100 total points
ID: 1318326
Here is a method I have used of sending signals to other processes on the system.  Its very unorthodox, but it works and it gets you into the memory space of the other process (sans source code) if that is of interest to you.

1)  Write a function in a DLL that will called whenever a specific Registered Windows message comes thru.   The purpose of your function would be defined by you.  You could use mapped memory or whatever you want if you want to do synchronization techniques.

2) In the same DLL write a windows proc hook with handling for your special registered windows message.

3) Install a system wide hook, so your DLL is mapped into the other process spaces across your system.

4) Register your own windows message (use the one your proc is expecting to receive). and have each instance of the hook proc (in the dll) register the message' to get its special windows assigned id.

Now when ever you want the other processes in the system to listen to what you want to do, you just either post a message to the given application, or across the whole system.


And thats about it....


0
 

Author Comment

by:akhila
ID: 1318327
Duneram,
  Thank you very much. I'll definitely try it.
-AKhila
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 100
Expand data scrubbing tool 13 32
Process filename extension 3 186
how to monitor remote shell execution on linux 9 100
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question