<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="unix-signal-response">
      </a>
      6.10 Unix Signal Handling in MySQL
     </h2>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045302561808">
  </a>
  <a class="indexterm" name="idm46045302560768">
  </a>
  <p>
   On Unix and Unix-like systems, a process can be the recipient of
      signals sent to it by the
   <code class="literal">
    root
   </code>
   system account
      or the system account that owns the process. Signals can be sent
      using the
   <a class="link" href="kill.html" title="15.7.8.4 KILL Statement">
    <span class="command">
     <strong>
      kill
     </strong>
    </span>
   </a>
   command. Some command
      interpreters associate certain key sequences with signals, such as
   <span class="keycap">
    <strong>
     Control+C
    </strong>
   </span>
   to send a
   <code class="literal">
    SIGINT
   </code>
   signal. This section describes how the MySQL server and client
      programs respond to signals.
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="unix-signal-response.html#server-signal-response" title="Server Response to Signals">
       Server Response to Signals
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="unix-signal-response.html#client-signal-response" title="Client Response to Signals">
       Client Response to Signals
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="server-signal-response">
       </a>
       Server Response to Signals
      </h3>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045302552032">
   </a>
   <a class="indexterm" name="idm46045302550576">
   </a>
   <a class="indexterm" name="idm46045302549088">
   </a>
   <a class="indexterm" name="idm46045302547600">
   </a>
   <a class="indexterm" name="idm46045302546112">
   </a>
   <a class="indexterm" name="idm46045302544624">
   </a>
   <p>
    <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
     <span class="command">
      <strong>
       mysqld
      </strong>
     </span>
    </a>
    responds to signals as follows:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        SIGTERM
       </code>
       causes the server to shut down.
            This is like executing a
       <a class="link" href="shutdown.html" title="15.7.8.9 SHUTDOWN Statement">
        <code class="literal">
         SHUTDOWN
        </code>
       </a>
       statement without
            having to connect to the server (which for shutdown requires
            an account that has the
       <a class="link" href="privileges-provided.html#priv_shutdown">
        <code class="literal">
         SHUTDOWN
        </code>
       </a>
       privilege).
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        SIGHUP
       </code>
       causes the server to reload the
            grant tables and to flush tables, logs, the thread cache,
            and the host cache. These actions are like various forms of
            the
       <a class="link" href="flush.html" title="15.7.8.3 FLUSH Statement">
        <code class="literal">
         FLUSH
        </code>
       </a>
       statement. Sending
            the signal enables the flush operations to be performed
            without having to connect to the server, which requires a
            MySQL account that has privileges sufficient for those
            operations.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        SIGUSR1
       </code>
       causes the server to flush the
            error log, general query log, and slow query log. One use
            for
       <code class="literal">
        SIGUSR1
       </code>
       is to implement log rotation
            without having to connect to the server, which requires a
            MySQL account that has privileges sufficient for those
            operations. For information about log rotation, see
       <a class="xref" href="log-file-maintenance.html" title="7.4.6 Server Log Maintenance">
        Section 7.4.6, “Server Log Maintenance”
       </a>
       .
      </p>
      <p>
       The server response to
       <code class="literal">
        SIGUSR1
       </code>
       is a
            subset of the response to
       <code class="literal">
        SIGHUP
       </code>
       ,
            enabling
       <code class="literal">
        SIGUSR1
       </code>
       to be used as a more
       <span class="quote">
        “
        <span class="quote">
         lightweight
        </span>
        ”
       </span>
       signal that flushes certain logs
            without the other
       <code class="literal">
        SIGHUP
       </code>
       effects such as
            flushing the thread and host caches and writing a status
            report to the error log.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        SIGINT
       </code>
       normally is ignored by the server.
            Starting the server with the
       <a class="link" href="server-options.html#option_mysqld_gdb">
        <code class="option">
         --gdb
        </code>
       </a>
       option installs an
            interrupt handler for
       <code class="literal">
        SIGINT
       </code>
       for
            debugging purposes. See
       <a class="xref" href="using-gdb-on-mysqld.html" title="7.9.1.4 Debugging mysqld under gdb">
        Section 7.9.1.4, “Debugging mysqld under gdb”
       </a>
       .
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="client-signal-response">
       </a>
       Client Response to Signals
      </h3>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045302520832">
   </a>
   <a class="indexterm" name="idm46045302519376">
   </a>
   <a class="indexterm" name="idm46045302517888">
   </a>
   <a class="indexterm" name="idm46045302516400">
   </a>
   <p>
    MySQL client programs respond to signals as follows:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       The
       <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
        <span class="command">
         <strong>
          mysql
         </strong>
        </span>
       </a>
       client interprets
       <code class="literal">
        SIGINT
       </code>
       (typically the result of typing
       <span class="keycap">
        <strong>
         Control+C
        </strong>
       </span>
       ) as instruction to interrupt the
            current statement if there is one, or to cancel any partial
            input line otherwise. This behavior can be disabled using
            the
       <a class="link" href="mysql-command-options.html#option_mysql_sigint-ignore">
        <code class="option">
         --sigint-ignore
        </code>
       </a>
       option to
            ignore
       <code class="literal">
        SIGINT
       </code>
       signals.
      </p>
     </li>
     <li class="listitem">
      <p>
       Client programs that use the MySQL client library block
       <code class="literal">
        SIGPIPE
       </code>
       signals by default. These
            variations are possible:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          Client can install their own
          <code class="literal">
           SIGPIPE
          </code>
          handler to override the default behavior. See
          <a class="ulink" href="/doc/c-api/8.4/en/c-api-threaded-clients.html" target="_top">
           Writing C API Threaded Client Programs
          </a>
          .
         </p>
        </li>
        <li class="listitem">
         <p>
          Clients can prevent installation of
          <code class="literal">
           SIGPIPE
          </code>
          handlers by specifying the
          <code class="literal">
           CLIENT_IGNORE_SIGPIPE
          </code>
          option to
          <a class="ulink" href="/doc/c-api/8.4/en/mysql-real-connect.html" target="_top">
           <code class="literal">
            mysql_real_connect()
           </code>
          </a>
          at
                connect time. See
          <a class="ulink" href="/doc/c-api/8.4/en/mysql-real-connect.html" target="_top">
           mysql_real_connect()
          </a>
          .
         </p>
        </li>
       </ul>
      </div>
     </li>
    </ul>
   </div>
  </div>
 </div>
 <br/>
</div>
