00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <stdio.h>
00019 #include <stdlib.h>
00020 #include <signal.h>
00021 #include <unistd.h>
00022 #include <e32def.h>
00023
00027 int gVal = TRUE;
00028
00033 void SIGUSR2_handler(int signum)
00034 {
00035 if(signum == SIGUSR2)
00036 {
00037 printf("Received the SIGUSR2 signal from the sigusr1 process after reading the file.\n");
00038 gVal = FALSE;
00039 }
00040 }
00041
00049 int main(int argc,char **argv)
00050 {
00051 pid_t asyProcsID;
00052 char ch;
00053 int ret;
00054 if(argc < 2)
00055 {
00056 printf("Please pass the correct arguments\n");
00057 return EXIT_FAILURE;
00058 }
00059 asyProcsID = atoi(argv[1]);
00060
00061 signal(SIGUSR2, SIGUSR2_handler);
00062 printf("******************** In the sigusr2 process ********************\n");
00063
00064 printf("\nPress the Enter key to send the SIGUSR1 signal to the sigusr1 process\n");
00065 getchar();
00066 ret = kill(asyProcsID,SIGUSR1);
00067 if(ret)
00068 {
00069 printf("kill() failed to send signal, errno=%d\n",errno);
00070 gVal = FALSE;
00071 }
00072
00073
00074
00075
00076
00077
00078 while(gVal)
00079 {
00080 sleep(0);
00081 }
00082 printf("\nPress 'e'+Enter to exit from the sigusr2 process\n");
00083 while((ch = getchar())!= 'e')
00084 {
00085 if(ch == '\n')
00086 continue;
00087 else
00088 printf("The wrong option was selected, please try again!!!\n");
00089 }
00090 return EXIT_SUCCESS;
00091 }