The issue I'm having is that whenever I just remove my USB wifi card, it kernel panics and reboots the system. Is there some way to detect and kill any processes using the wifi card automatically to make some sort of shell script?

  • Can you unmount it before removal without problems? unix.stackexchange.com/questions/45820/…
    – iyrin
    Nov 3 '14 at 15:01
  • If you're running on Linux netstat -tuapn | grep <IP Address> should tell you what processes/PIDs are using the IP address.
    – Bratchley
    Nov 3 '14 at 15:37
  • 2
    But like Gareth says, an application using the WiFi stick shouldn't cause the kernel to panic. The root cause is probably at the kernel level.
    – Bratchley
    Nov 3 '14 at 15:41
  • There is no notion of “process using a network interface” (apart from some very low-level network diagnostics programs). There is a layer of isolation between processes and network interfaces; processes talk TCP (mostly) and all information about routing TCP packets through network interfaces keeps inside the kernel. Nov 3 '14 at 23:06
  • @Gilles service ifplugd status may respond something like wlan0: ifplugd process for device wlan0 running as pid 1234 (and one can kill it with sudo ifplugd -k -i wlan0). I guess what you say implies that there is no generic way to detect all processes like ifplugd?
    – RolfBly
    Jun 11 '17 at 20:06

I suspect that the issue is with your driver rather than any process using it.

You'll need to make sure that nothing is using it and then remove it with modprobe -r. Try bringing down the network interface first. For example:

# ip link set wlan0 down
# modprobe -r <module>

You can find out the module name using lsusb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.