Merge branch 'master' of git+ssh://github.com/adefaria/clearscm
[clearscm.git] / bin / announceEmail.pl
index a864634..cb6667b 100755 (executable)
@@ -75,9 +75,10 @@ use warnings;
 
 use FindBin;
 use Getopt::Long;
-use Pod::Usage;
 use Mail::IMAPTalk;
 use MIME::Base64;
+use Pod::Usage;
+use Proc::ProcessTable;
 
 use lib "$FindBin::Bin/../lib";
 
@@ -89,6 +90,16 @@ use Utils;
 
 local $0 = "$FindBin::Script " . join ' ', @ARGV;
 
+my $processes = Proc::ProcessTable->new;
+
+for my $process (@{$processes->table}) {
+  if ($process->cmndline eq $0 and $process->pid != $$) { 
+    verbose "$FindBin::Script already running";
+
+    exit 0;
+  } # if
+} # for
+
 my $defaultIMAPServer = 'defaria.com';
 my $IMAP;
 my %unseen;