Google code style

This commit is contained in:
Isaac Connor 2018-04-25 10:48:50 -04:00
parent 117555a857
commit 27531750a4
1 changed files with 110 additions and 114 deletions

View File

@ -118,7 +118,7 @@ if ( $command eq 'version' ) {
exit(0);
}
my $needs_daemon = $command !~ /(?:startup|shutdown|status|check|logrot|version)/;
my $daemon = shift( @ARGV );
my $daemon = shift @ARGV;
if ( $needs_daemon && ! $daemon ) {
print(STDERR "No daemon given\n");
pod2usage(-exitstatus => -1);
@ -209,7 +209,6 @@ if ( ($command eq 'check') && !$daemon ) {
}
# The server is there, connect to it
#print( "Writing commands\n" );
CLIENT->autoflush();
my $message = join(';', $command, ( $daemon ? $daemon : () ), @args );
print(CLIENT $message);
@ -218,9 +217,7 @@ while( my $line = <CLIENT> ) {
chomp($line);
print("$line\n");
}
# And we're done!
close(CLIENT);
#print( "Finished writing, bye\n" );
exit;
@ -319,7 +316,7 @@ sub run {
next if !$message;
my ( $command, $daemon, @args ) = split( /;/, $message );
my ( $command, $daemon, @args ) = split(';', $message);
if ( $command eq 'start' ) {
start($daemon, @args);
@ -425,7 +422,7 @@ sub start {
.strftime('%y/%m/%d %H:%M:%S', localtime($process->{started}))
.", pid = $process->{pid}\n"
);
return();
return;
}
my $sigset = POSIX::SigSet->new;
@ -436,7 +433,7 @@ sub start {
$process->{pid} = $cpid;
$process->{started} = time();
delete( $process->{pending} );
delete $process->{pending};
dPrint(ZoneMinder::Logger::INFO, "'$command' starting at "
.strftime('%y/%m/%d %H:%M:%S', localtime($process->{started}))
@ -450,8 +447,7 @@ sub start {
$dbh = zmDbConnect(1);
logReinit();
dPrint( ZoneMinder::Logger::INFO, "'".join( ' ', ( $daemon, @args ) )
."' started at "
dPrint(ZoneMinder::Logger::INFO, "'$command' started at "
.strftime('%y/%m/%d %H:%M:%S', localtime())
."\n"
);
@ -466,7 +462,7 @@ sub start {
foreach my $arg ( @args ) {
# Detaint arguments, if they look ok
if ( $arg =~ /^(-{0,2}[\w\/?&=.-]+)$/ ) {
push( @good_args, $1 );
push @good_args, $1;
} else {
Fatal("Bogus argument '$arg' found");
}
@ -490,7 +486,7 @@ sub start {
} else {
Fatal("Can't fork: $!");
}
}
} # end sub start
# Sends the stop signal, without waiting around to see if the process died.
sub send_stop {
@ -499,7 +495,7 @@ sub send_stop {
my $command = $process->{command};
if ( $process->{pending} ) {
delete( $cmd_hash{$command} );
delete $cmd_hash{$command};
dPrint(ZoneMinder::Logger::INFO, "Command '$command' removed from pending list at "
.strftime('%y/%m/%d %H:%M:%S', localtime())
."\n"
@ -522,7 +518,6 @@ sub send_stop {
$process->{pending} = 0;
$terminating_processes{$command} = $process;
kill('TERM', $pid);
return $pid;
} # end sub send_stop
@ -534,6 +529,7 @@ sub check_for_processes_to_kill {
sigprocmask(SIG_BLOCK, $blockset, $sigset) or die "dying at block...\n";
foreach my $command ( %terminating_processes ) {
my $process = $cmd_hash{$command};
Debug("Have process $command at pid $$process{pid} $$process{term_sent_at}");
if ( $$process{term_sent_at} - time > KILL_DELAY ) {
dPrint(ZoneMinder::Logger::WARNING, "'$$process{command}' has not stopped at "
.strftime('%y/%m/%d %H:%M:%S', localtime())
@ -591,7 +587,7 @@ sub reload {
sub logrot {
logReinit();
foreach my $process ( values(%pid_hash) ) {
foreach my $process ( values %pid_hash ) {
if ( $process->{pid} ) {
# && $process->{command} =~ /^zm.*\.pl/ ) {
kill('HUP', $process->{pid});