title: perl Win32 Signal Handling between perl processes
body: <p>I have a couple long running perl scripts in windows (strawberry perl) that I'm working on.</p>
  
  <ol>
  <li>The first process is a parent monitoring process. It restarts the child process every 24 hours and will be always running.</li>
  <li>The second is the child payment processing script. It is imperative that this process completes whatever it's doing before being shutdown.</li>
  </ol>
  
  <p>It's my understanding that signal handling <a href="http://perldoc.perl.org/perlport.html#System-Interaction" rel="nofollow">doesn't work</a> in perl on win32 and that it shouldn't be relied on. Is there some other way that I can handle a signal? <code>Win32::Process::Kill</code> seems to kill the process without letting it safely shut down.</p>
  
  <p>This is the signal handling that I've tried...</p>
  
  <pre><code>#Child
  my $interrupted = 0;
  $SIG{INT} = sub{$interrupted = 1;};
  while(!$interrupted){
    #keep doing your thing, man
  }
  
  #Parent
  my $pid = open2(\*CHLD_OUT,\*CHLD_IN,'C:\\strawberry\\perl\\bin\\perl.exe','process.pl');
  kill INT=&gt;$pid;
  waitpid($pid,0);
  </code></pre>
  
  <p>The only other thing I can think of is to open a socket between the two processes and write messages across the socket. But there must be something easier. Anyone know of any module that can do this?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I've started working on creating a "<em>signal</em>" mechanism via <code>IO::Socket::INET</code> and <code>IO::Select</code> by <a href="https://gist.github.com/gordolio/9371193" rel="nofollow">opening a socket</a>. This appears to work and I'm thinking of writing a module that is compatible with <a href="https://metacpan.org/pod/AnyEvent#SYNOPSIS" rel="nofollow">AnyEvent</a>. But I'm still interested in an implementation that doesn't require opening a listening port and that doesn't require a server/client relationship. Is it possible to do this by subscribing to and firing custom events in windows?</p>