// Copyright (c) 2008 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
//
// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "atf-c++/detail/process.hpp"
extern "C" {
#include <signal.h>
}
#include <iostream>
#include "atf-c++/detail/exceptions.hpp"
#include "atf-c++/detail/sanity.hpp"
// ------------------------------------------------------------------------
// Auxiliary functions.
// ------------------------------------------------------------------------
template< class C >
atf::auto_array< const char* >
collection_to_argv(const C& c)
{
iter++) {
pos++;
}
return argv;
}
template< class C >
C
{
C c;
return c;
}
// ------------------------------------------------------------------------
// The "argv_array" type.
// ------------------------------------------------------------------------
{
}
{
{
const char* nextarg;
}
}
{
}
{
}
void
{
}
const char* const*
const
{
return m_exec_argv.get();
}
const
{
}
const char*
const
{
}
const
{
}
const
{
}
{
if (this != &a) {
}
return *this;
}
// ------------------------------------------------------------------------
// The "stream" types.
// ------------------------------------------------------------------------
m_inited(false)
{
}
{
if (m_inited)
}
const atf_process_stream_t*
const
{
return &m_sb;
}
{
if (atf_is_error(err))
m_inited = true;
}
{
if (atf_is_error(err))
m_inited = true;
}
{
if (atf_is_error(err))
m_inited = true;
}
{
if (atf_is_error(err))
m_inited = true;
}
{
if (atf_is_error(err))
m_inited = true;
}
// ------------------------------------------------------------------------
// The "status" type.
// ------------------------------------------------------------------------
m_status(s)
{
}
{
}
bool
const
{
return atf_process_status_exited(&m_status);
}
int
const
{
return atf_process_status_exitstatus(&m_status);
}
bool
const
{
return atf_process_status_signaled(&m_status);
}
int
const
{
return atf_process_status_termsig(&m_status);
}
bool
const
{
return atf_process_status_coredump(&m_status);
}
// ------------------------------------------------------------------------
// The "child" type.
// ------------------------------------------------------------------------
m_child(c),
m_waited(false)
{
}
{
if (!m_waited) {
}
}
{
if (atf_is_error(err))
m_waited = true;
return status(s);
}
const
{
return atf_process_child_pid(&m_child);
}
int
{
return atf_process_child_stdout(&m_child);
}
int
{
return atf_process_child_stderr(&m_child);
}
// ------------------------------------------------------------------------
// Free functions.
// ------------------------------------------------------------------------
void
{
// TODO: This should only be executed when inheriting the stdout or
// stderr file descriptors. However, the flushing is specific to the
// iostreams, so we cannot do it from the C library where all the process
// logic is performed. Come up with a better design.
}