    # File lib/chef/application/client.rb, line 211
      def run_application
        unless RUBY_PLATFORM =~ /mswin|mingw32|windows/
          SELF_PIPE.replace IO.pipe

          trap("USR1") do
            Chef::Log.info("SIGUSR1 received, waking up")
            SELF_PIPE[1].putc('.') # wakeup master process from select
          end
        end

        if Chef::Config[:version]
          puts "Chef version: #{::Chef::VERSION}"
        end

        if Chef::Config[:daemonize]
          Chef::Daemon.daemonize("chef-client")
        end

        loop do
          begin
            if Chef::Config[:splay]
              splay = rand Chef::Config[:splay]
              Chef::Log.debug("Splay sleep #{splay} seconds")
              sleep splay
            end
            @chef_client = Chef::Client.new(@chef_client_json)
            @chef_client_json = nil

            @chef_client.run
            @chef_client = nil
            if Chef::Config[:interval]
              Chef::Log.debug("Sleeping for #{Chef::Config[:interval]} seconds")
              unless SELF_PIPE.empty?
                client_sleep Chef::Config[:interval]
              else
                # Windows
                sleep Chef::Config[:interval]
              end
            else
              Chef::Application.exit! "Exiting", 0
            end
          rescue Chef::Application::Wakeup => e
            Chef::Log.debug("Received Wakeup signal.  Starting run.")
            next
          rescue SystemExit => e
            raise
          rescue Exception => e
            if Chef::Config[:interval]
              Chef::Log.error("#{e.class}: #{e}")
              Chef::Application.debug_stacktrace(e)
              Chef::Log.error("Sleeping for #{Chef::Config[:interval]} seconds before trying again")
              unless SELF_PIPE.empty?
                client_sleep Chef::Config[:interval]
              else
                # Windows
                sleep Chef::Config[:interval]
              end
              retry
            else
              Chef::Application.debug_stacktrace(e)
              Chef::Application.fatal!("#{e.class}: #{e.message}", 1)
            end
          ensure
            GC.start
          end
        end
      end