You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2017/04/18 14:42:58 UTC
[4/5] incubator-trafficcontrol git commit: revert execCommand -- need
return status
revert execCommand -- need return status
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/e45681d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/e45681d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/e45681d7
Branch: refs/heads/master
Commit: e45681d7219710ba82e5a4cf10b7400b2b42787a
Parents: 7addd62
Author: Dan Kirkwood <da...@gmail.com>
Authored: Mon Apr 17 11:21:06 2017 -0600
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Tue Apr 18 08:42:25 2017 -0600
----------------------------------------------------------------------
traffic_ops/install/lib/InstallUtils.pm | 42 +++-------------------------
1 file changed, 4 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e45681d7/traffic_ops/install/lib/InstallUtils.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/install/lib/InstallUtils.pm b/traffic_ops/install/lib/InstallUtils.pm
index 1b9cf72..040a8e9 100644
--- a/traffic_ops/install/lib/InstallUtils.pm
+++ b/traffic_ops/install/lib/InstallUtils.pm
@@ -50,44 +50,10 @@ sub initLogger {
}
sub execCommand {
- my ( $command, @args ) = @_;
-
- my $pipe = IO::Pipe->new;
- my $pid;
- my $result = 0;
- my $customLog = "";
-
- # find log file in args and remove if found
- # if there is a string in the list of args which starts with 'pi_custom_log=' then remove it from the parameters and use
- # it as the log file for the exec
- foreach my $var (@args) {
- if ( index( $var, "pi_custom_log=" ) != -1 ) {
- $customLog = ( split( /=/, $var ) )[1];
- splice( @args, index( $var, "pi_custom_log=" ), 1 );
- logger( "Using custom log '$customLog'", "info" );
- }
- }
-
- # create pipe between child and parent and redirect output from child to parent for logging
- my $child = open READER, '-|';
- defined $child or die "pipe/fork: $!\n";
- if ($child) { #parent
- while ( $line = <READER> ) {
-
- # log all output from child pipe
- if ( $customLog ne "" ) {
- logger( $line, "info", $customLog );
- }
- else {
- logger( $line, "info" );
- }
- }
- }
- else { #child
- # redirect stderr to stdout so parent can read
- open STDERR, '>&STDOUT';
- exec( $command, @args ) or exit(1);
- }
+ my ( $cmd, @args ) = @_;
+ system( $cmd, @args );
+ my $result = $? >> 8;
+ return $result;
}
# log the error and then kill the process