I'm using uclinux and I want to find out which processes are using the serial port. The problem is that I have no lsof or fuser.

Is there any other way I can get this information?


This one-liner should help:

ls -l /proc/[0-9]*/fd/* |grep /dev/ttyS0

replace ttyS0 with actual port name

example output:

lrwx------ 1 root dialout 64 Sep 12 10:30 /proc/14683/fd/3 -> /dev/ttyUSB0

That means the pid 14683 has the /dev/ttyUSB0 open as file descriptor 3

  • 1
    Running as root, of course :-) – Stephen Harris Sep 9 '16 at 18:03
  • I did the following : root:/mnt/app> ls -l /proc/[0-9]*/fd/* | grep /dev/ttyBF0. The output I get is ls: /proc/354/fd/3: No such file or directory. Forgive my ignorance, but what do I make of that? – Kermit the Hermit Sep 12 '16 at 7:26
  • This method is not 100% reliable; though it did not find any processes that have ttyBF0 open, I would check what is pid 354 – Serge Sep 12 '16 at 7:29
  • @KermittheHermit see the edit, please – Serge Sep 12 '16 at 7:35
  • @Serge I've tested this on my laptop with USB to serial adapter. I encounter the same issue even though I'm using /dev/ttyUSB. Do you perhaps have any idea why this is happening? – Kermit the Hermit Sep 12 '16 at 8:34

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.