Forgot to close a device file ... what now?

Roman Suzi rnd at onego.ru
Sun Sep 16 01:03:26 EDT 2001


On Sat, 15 Sep 2001, Ignacio Vazquez-Abrams wrote:

>On 15 Sep 2001, Jyrinx wrote:
>
>> Hey - Python newbie here. I'm running Python on Red Hat Linux 7.1. At
>> the interpreter prompt, I ran "fd = open("/dev/ttyS0", "wb")", then
>> went off to do something else, came back, forgot to close the file,
>> then quit Python. Next time I ran the interpreter, I tried to open the
>> serial port again, but I got an error saying the file is locked or
>> busy.
>>
>> What can I do to reopen it, short of resetting the system?
>
>Interesting. Normally Python should close the file. If not Python, then C
>should close it. If C doesn't close the file, then there may be a problem.
>
>Try 'lsof | grep ttyS0' and see if the file is still being held open. If so,
>then you can kill the program that is holding it open. If not, then a reboot
>is called for.

fuser -v /dev/ttyS0
gives you who uses ttyS0

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Sunday, September 16, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Phobia: what's left after drinking 2 out of a 6 pack" _/





More information about the Python-list mailing list