Opened 4 years ago

#13605 new Bugs

Filedescriptor leak in boost::process

Reported by: 4hopp Owned by:
Milestone: To Be Determined Component: process
Version: Boost 1.64.0 Severity: Problem
Keywords: Cc:

Description

Hi,

I am using boost 1.64.0 on linux. I am using boost process to execute subprocesses. When, for some reason, the path does not point to a file, or when the file is not executable, then I keep leaking file descriptors.

Minimal example:

#include <boost/process.hpp>
#include <boost/process/extend.hpp>
#include <boost/filesystem.hpp>
#include <boost/asio.hpp>
#include <sys/prctl.h>

int main() {
        namespace bp = boost::process;
        namespace ex = bp::extend;

        system("ls -l /proc/self/fd");

        try {
                boost::asio::io_service ios;
                bp::child process ("/does/not/exist", ios);
                process.wait();
        } catch (const bp::process_error& e) {
                // A process_error has been thrown - there is no file /does/not/exist
        }

        system("ls -l /proc/self/fd");
}

Example output:

total 0
lrwx------ 1 hopp hopp 64 Jun 14 12:04 0 -> /dev/pts/3
lrwx------ 1 hopp hopp 64 Jun 14 12:04 1 -> /dev/pts/3
lrwx------ 1 hopp hopp 64 Jun 14 12:04 2 -> /dev/pts/3
lr-x------ 1 hopp hopp 64 Jun 14 12:04 3 -> /proc/19629/fd
total 0
lrwx------ 1 hopp hopp 64 Jun 14 12:04 0 -> /dev/pts/3
lrwx------ 1 hopp hopp 64 Jun 14 12:04 1 -> /dev/pts/3
lrwx------ 1 hopp hopp 64 Jun 14 12:04 2 -> /dev/pts/3
lr-x------ 1 hopp hopp 64 Jun 14 12:04 3 -> pipe:[82382]
lr-x------ 1 hopp hopp 64 Jun 14 12:04 4 -> /proc/19632/fd

The file descriptor leaked by the example is 3 -> pipe:[82382]. Is this a bug or am I doing something wrong?

Change History (0)

Note: See TracTickets for help on using tickets.