PageRenderTime 56ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/swatch-3.2.3/tools/reswatch

#
Perl | 37 lines | 26 code | 10 blank | 1 comment | 4 complexity | da6f99147c6bd8d49312823eba76d6d1 MD5 | raw file
Possible License(s): GPL-2.0
  1. #!/usr/bin/perl
  2. =head1 NAME
  3. reswatch - Restart Swatch
  4. =head1 DESCRIPTION
  5. B<Reswatch> attempts to send a HUP signal to a swatch process. It finds the
  6. process ID of B<swatch> by looking for a file named I<.swatch_script.>B<PID>
  7. in the home directory.
  8. =head1 SEE ALSO
  9. b<swatch(1)>
  10. =cut
  11. use DirHandle;
  12. my $script_prefix = '.swatch_script';
  13. my $homedir = $ENV{'HOME'};
  14. my $dh = new DirHandle $homedir;
  15. if (defined $dh) {
  16. while (defined($_ = $dh->read)) {
  17. if (/^${script_prefix}\.[0-9]*/) {
  18. split(/\./, $_);;
  19. print "Sending HUP signal to PID $_[$#_]\n";
  20. kill('HUP', $_[$#_]);
  21. undef $dh;
  22. exit 0;
  23. }
  24. }
  25. }
  26. undef $dh;
  27. exit 1;