title: `libusb_attach_kernel_driver` not working
body: <p>I have a problem shutting down cleanly my Linux application that uses <code>libusb</code> (the kernel does not reclaim the interface):</p>
  
  <pre><code>int rc;
  
  rc = libusb_reset_device(handle_);
  if (rc &lt; 0) {
      cerr &lt;&lt; "Error resetting the device: " &lt;&lt; libusb_error_name(rc);
  }
  
  for (int ifnum = 0; ifnum &lt; 2; ifnum++) {
      rc = libusb_release_interface(handle_, ifnum);
      if (rc &lt; 0) {
          cerr &lt;&lt; "Error releasing interface: " &lt;&lt; libusb_error_name(rc);
      }
      if (libusb_kernel_driver_active(handle_, ifnum)) {
          cerr &lt;&lt; "Reattaching CDC ACM kernel driver.";
          rc = libusb_attach_kernel_driver(handle_, ifnum);
          if (rc &lt; 0) {
              cerr &lt;&lt; "Error reattaching CDC ACM kernel driver: " &lt;&lt; libusb_error_name(rc);
          }
      }
  }
  
  libusb_close(handle_);
  libusb_exit(NULL);
  </code></pre>
  
  <p>The problem is that the reattaching the kernel driver does not work. Actually <code>libusb_kernel_driver_active</code> does not return 1 but even if I comment it out and always call <code>libusb_attach_kernel_driver</code>, I never get back my <code>/dev/ttyACM0</code> device. In this case I get <code>LIBUSB_ERROR_NOT_FOUND</code>.</p>