question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

file-descriptors remain open when stop() is called

See original GitHub issue

Mininet does not close all file descriptors if it is stopped by function Mininet.stop(). This is because the pipes of the Pseduo-TTY remain open when the network shuts down. Implementation of Node.startShell() opens these pipes, but they are not closed when the network is stopped:

        self.master, self.slave = pty.openpty()
        self.shell = self._popen( cmd, stdin=self.slave, stdout=self.slave, stderr=self.slave,
                                  close_fds=False )
        self.stdin = os.fdopen( self.master, 'rw' )

A possible solution for this bug could be an extension of Node.cleanup():

def cleanup( self ):
        self.shell = None 

        """close pipes of shell"""
        if self.master: 
            os.close(self.master)
            self.master = None
        if self.slave: 
            os.close(self.slave)
            self.slave = None

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cw299commented, Oct 22, 2018

The problem is actually not the master, but stdin When both slave and stdin are closed, it works:

def cleanup( self ):
        self.shell = None 

        """close pipes of shell"""
        if self.slave: 
            os.close(self.slave)
            self.slave = None
        self.stdin.close()
0reactions
lantzcommented, Oct 29, 2018

closing - fixed in master

Read more comments on GitHub >

github_iconTop Results From Across the Web

What happens to file descriptors when the process is killed?
Yes, the file will be automatically closed when the process terminates, regardless of the reason for the process termination.
Read more >
Why should I close all file descriptors after calling fork() and ...
If you don't want to close all file descriptors in a loop on macOS, your only option is to not use fork() /...
Read more >
Using file descriptors - IBM
A file descriptor is an unsigned integer used by a process to identify an open file.
Read more >
File descriptor - Wikipedia
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or...
Read more >
open(2) - Linux manual page - man7.org
The return value of open() is a file descriptor, a small, nonnegative integer that is an index to an entry in the process's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found