title: How to exit the process in B program process, if input is -1 using signal in C
body: <p>I would execute both process in A program and process in B program.</p>
  <p>first of all, A program is executed.</p>
  <p>and then, B program is executed.</p>
  <p>A program and B program are sharing one data file.</p>
  <p>A =&gt; input from user and then write a number to data file.
  B =&gt; read number from data file which is written by A</p>
  <p>I want to do implementation that is process in A program input -1 and exit the A program</p>
  <p>also, process in B program is finished using signal.</p>
  <p>structure --</p>
  <p>A sent sigusr1 to B
  B sent sigint to A</p>
  <p>example</p>
  <p>A  : -1 (input) , print bye</p>
  <p>B  : print bye</p>
  <p>How to send A program a sigusr1 to B program for this?</p>
  <p>I'm thinking about this for a few days.</p>
  <p>Thank you.</p>
  <p>A program</p>
  <pre><code>do {
              scanf(&quot;%d&quot;,&amp;num);
              if(num &gt; 0)
              {
                      lseek(fd,0,SEEK_SET);
                      write(fd,&amp;num,sizeof(num));
                      printf(&quot;writes ..... %d\n\n&quot;,num);
                      kill(bproc,SIGUSR1);
                      pause();
              }
              else
              {
                      kill(bproc,SIGUSR1);
  
              }
      } while ( num &gt; 0 );
      printf(&quot;bye...\n&quot;);
  </code></pre>
  <p>B program</p>
  <pre><code> while(rdnum &gt; 0)
      {
              lseek(fd,0,SEEK_SET);
              read(fd,&amp;rdnum,sizeof(int));
              printf(&quot;reads...  %d\n\n&quot;,rdnum);
              kill(Aproc,SIGINT);
              pause();
      }
  
      printf(&quot;bye...\n&quot;);
      exit(0);
  </code></pre>