/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
- #!/usr/bin/perl
- =head1 NAME
- reswatch - Restart Swatch
- =head1 DESCRIPTION
- B<Reswatch> attempts to send a HUP signal to a swatch process. It finds the
- process ID of B<swatch> by looking for a file named I<.swatch_script.>B<PID>
- in the home directory.
- =head1 SEE ALSO
- b<swatch(1)>
- =cut
- use DirHandle;
- my $script_prefix = '.swatch_script';
- my $homedir = $ENV{'HOME'};
- my $dh = new DirHandle $homedir;
- if (defined $dh) {
- while (defined($_ = $dh->read)) {
- if (/^${script_prefix}\.[0-9]*/) {
- split(/\./, $_);;
- print "Sending HUP signal to PID $_[$#_]\n";
- kill('HUP', $_[$#_]);
- undef $dh;
- exit 0;
- }
- }
- }
- undef $dh;
- exit 1;