Advertisement
folays

check_duplicate

Jun 26th, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.27 KB | None | 0 0
  1. sub check_duplicate
  2. {
  3.     (my $cmdline = qx(cat /proc/$$/cmdline)) =~ s/(?:\0(?!$))\0?/ /go;
  4.     open my $fh, "-|", "pgrep", "-x", "-f", $cmdline or die;
  5.     do { print "duplicate instance\n" if -t STDIN; exit } if scalar @{[<$fh>]} >= 2;
  6.     close $fh;
  7. }
  8. &check_duplicate;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement