run

in chefctl/src/chefctl.rb [1056:1106]


    def run
      if Chefctl.lib.is_a?(Chefctl::Lib::Windows) &&
         Chefctl::Config.windows_subshell
        
        
        
        
        
        
        Chefctl.logger.warn("Deprecated: windows_subshell shouldn't be used")
        cmd = get_chef_cmd.join(' ')
        chef_client =
          Chefctl::Lib::Windows.run_chef_via_subshell(cmd.freeze)
      else
        Chefctl.flush_logger
        output_t = output_copier_thread

        unless Chefctl.log_file
          Chefctl.logger.warn(
            'chefctl log file is nil!' +
            "Redirecting chef-client's output to the shell!",
          )
        end
        chef_client_pid = Process.spawn(
          get_chef_env,
          *get_chef_cmd,
          
          
          
          
          [:out, :err] => (Chefctl.log_file ? Chefctl.log_file.to_i : STDERR),
          :close_others => true,
          
          
          :unsetenv_others => !Chefctl.lib.is_a?(Chefctl::Lib::Windows),
        )
        chef_client = Process.wait2(chef_client_pid)[1]

        
        if output_t
          
          
          
          output_t.raise('this is normal')
          output_t.join(3)
        end
      end

      return chef_client.exitstatus
    end