Hi,
I'm experiencing a problem with signals between two processes. One process registers two simple signal handlers and runs an infinite loop. The other sends it a SIGUSR1 to pause it, runs a bit of code, and then sends SIGUSR2 to awaken it. Thus far it works fine.
However, if you try to run the sending process a second time while the first is still running, the looping process will quit instead of pausing and resuming again.
Any idea what's wrong?
Here's the code... note the sending process has to run with an argument which is the pid of the looping process.
handler.c
Code:
#include <stdio.h>
#include <signal.h>
void hpause(int signo)
{
pause();
}
void hresume(int signo)
{
}
int main(int argc, char ** argv)
{
signal(SIGUSR1, hpause);
signal(SIGUSR2, hresume);
while (1)
printf("1 ");
}
pause.c
Code:
#include <stdio.h>
#include <signal.h>
#define OTHERPROCES atoi(argv[i])
int main(int argc, char ** argv)
{
int i = 0;
kill(OTHERPROCESS, SIGUSR1);
for (i = 0; i < 100000; i++)
printf("a b c d e f g ");
kill(OTHERPROCESS, SIGUSR2);
}