title: Differentiate between exit and session timeout
body: <p>I have the following requierements:</p>
  
  <ul>
  <li>produce audit log when bash session has been terminated by the user (exit)</li>
  <li>produce audit log when bash session has timed out</li>
  </ul>
  
  <p>Those audit logs must be different. I am playing around with the following script <code>trap.sh</code>:</p>
  
  <pre><code>export TMOUT=10
  
  function handle-timeout {
      echo "Timeout"
  }
  
  function handle-exit {
      echo "Exit"
  }
  
  trap handle-exit EXIT
  </code></pre>
  
  <p>Now if I do:</p>
  
  <pre><code>valegon@precision ~ (master) $ bash
  valegon@precision ~ (master) $ source trap.sh
  valegon@precision ~ (master) $ exit
  Exit
  </code></pre>
  
  <p>It works as expected. If instead, I wait for the timeout to happen:</p>
  
  <pre><code>valegon@precision ~ (master) $ bash
  valegon@precision ~ (master) $ source trap.sh
  valegon@precision ~ (master) $ timed out waiting for input: auto-logout
  Exit
  </code></pre>
  
  <p>There are two problems here:</p>
  
  <ol>
  <li>the timeout is triggering EXIT, which I do not want</li>
  <li>I do not know how to trap the timeout specifically</li>
  </ol>
  
  <p>How can I solve these open issues?</p>