Results 1 to 4 of 4
Hi. I'm having quite a headache trying to communicate two processes which have no relation (one is not the child of the other). I use SIGUSR1 for this purpose. i ...
- 06-27-2009 #1Just Joined!
- Join Date
- Jun 2009
- Posts
- 3
Using signals between unrelated processes (C)
Hi. I'm having quite a headache trying to communicate two processes which have no relation (one is not the child of the other). I use SIGUSR1 for this purpose. i just want to send one signal from process 1 to process 2 so that this last process prints something in the console. Instead, it prints "User defined signal 1" and exits. I know this is the default behaviour but i'm installing a signal handler which supposedly just prints something. Any help'll be appreciated. Thanks
- 06-28-2009 #2
Well, it would be helpful to see your source. It should look something like so
The "struct sigaction" is defined in signal.h, so sa.sa_flags is defined as such in there. sa.sa_sigaction is just a pointer to a function which is the signal handler.Code:#include <signal.h> ... static void handler(int sig, siginfo_t *si, void *unused) { printf("%.2lf cps\n", (float)count/(time(0) - start)); } ... struct sigaction sa; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); sa.sa_sigaction = handler; if (sigaction(SIGUSR1, &sa, NULL) == -1) ;
As far as sending a SIGUSR1 to another process, I'm not sure how one would do this in C, I have just done it with the "kill" application".
- 06-28-2009 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Do note that to set a signal on another process, you either have to be the owner of that process, or root. This keeps one user from killing processes of another user.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-29-2009 #4


Reply With Quote
