Forgot to close a device file ... what now?
Ignacio Vazquez-Abrams
ignacio at openservices.net
Sat Sep 15 23:27:11 EDT 2001
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.
--
Ignacio Vazquez-Abrams <ignacio at openservices.net>
More information about the Python-list
mailing list