After closing spawn id, file desc. remains

  • John Forestal

    John Forestal - 2009-04-27

    I am running a Tcl/Tk based test API.  I have incorporated using a socket connection to be able to talk to any test bed or test equipment that has an IP address in our lab from any Linux PC that has the API installed on it.  The scripts that are run basically open a connection to a test bed, execute whatever commands and then close the connection.  Then on to the next connection, etc.  The open command is as follows:
    set code [catch {spawn -noecho -open [socket $ip_addr $ip_port]} reason]

    The close command is:
    exp_close -i $spawnid 
        where spawnid is the same as was created by the previous spawn command.

    The problem is, after the close, there remains a file descriptor with the same number as the spawned process.  For example, if the spawn created process exp45, there is now a file descriptor of 45r with name /dev/null.  Since the scripts being executed have numerous devices to talk to and hundreds of loops within the scripts for each device/testbed, there are literally thousands of these file descriptors being created, and eventually the dreaded "too many open files" message.

    Has anyone else come across this and/or does anyone know how to delete these fd's?

    • John Forestal

      John Forestal - 2009-04-27

      Never mind, I figured it out.  Putting the following line after the exp_close solves the problem:

      wait -i $spawnid

      This causes a wait until the process goes away, thus removing the file descriptor.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks