LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Main thread sending notification to child thread (https://www.linuxquestions.org/questions/programming-9/main-thread-sending-notification-to-child-thread-233790/)

rajesh_b 09-22-2004 07:26 AM

Main thread sending notification to child thread
 
I want to know whether there is a mechanism/function in c in which main thread can send notification to the child thread about some event. And whether main thread can know the status of child thread i.e. whether it is running or sleeping etc. Can main thread restart the child thread with out actually killing it? what happens if main thread kills the child one and if child is in the middle of some process. I am using posix thread library <pthread.h>. If anyone can clarify this issue?

thanx in advance.
rajesh.

rjlee 09-22-2004 09:15 AM

There are several methods of inter-thread communication, including named pipes and shared memory. But what you want here I suspect is a signal (see the signal manpage for more).

You can find out the status of another process by examining the /proc/PID directory, and by function calls. I don't know how to do this but you may want to look at the source code for “top” to get some ideas.

If the child thread gets killed, it will die in the middle of whatever it's doing. What happens then depends on several factors, including how you killed it.


All times are GMT -5. The time now is 11:30 AM.