Sha256: 5af3a7a20534d615793a67bfec23b098389dea320d72cef1f42e2662fb8534cc

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

#include <leatherman/execution/execution.hpp>
#include <leatherman/locale/locale.hpp>
#include "../platform.hpp"

// Mark string for translation (alias for leatherman::locale::format)
using leatherman::locale::_;

namespace leatherman { namespace execution {

    pid_t create_child(leatherman::util::option_set<execution_options> const& options,
                       int in_fd, int out_fd, int err_fd, uint64_t max_fd,
                       char const* program, char const** argv, char const** envp)
    {
        // Fork the child process
        // Note: this uses vfork (unless the thread_safe execution option is specified), which is inherently unsafe
        // (the parent's address space is shared with the child)
        pid_t pid = options[execution_options::thread_safe] ? fork() : vfork();
        if (pid < 0) {
            throw execution_exception(format_error(_("failed to fork child process")));
        }

        if (pid == 0) {  // Is this the child process?
            // Exec the child; this never returns
            exec_child(in_fd, out_fd, err_fd, max_fd, program, argv, envp);
        }

        return pid;
    }

}}  // namespace leatherman::execution

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.12.1.cfacter.20181031 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.11.6.cfacter.20181031 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.12.1.cfacter.20181023 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.11.5.cfacter.20181022 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.12.0.cfacter.20181004 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.12.0.cfacter.20181001 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.12.0.cfacter.20180918 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.11.4.cfacter.20180821 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.11.3.cfacter.20180716 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.11.2.cfacter.20180612 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.9.6.cfacter.20180612 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.11.2.cfacter.20180606 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.9.6.cfacter.20180606 ext/facter/leatherman/execution/src/posix/generic/platform.cc
facter-3.11.0.cfacter.20180319 ext/facter/leatherman/execution/src/posix/generic/platform.cc
cfacter-3.11.0.rc.20180314 ext/facter/leatherman/execution/src/posix/generic/platform.cc