mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 21:21:37 +00:00
- a child process that hangs blocked execute() until the caller was killed (e.g. by the ctest timeout); the child then ran on as an orphan, with its shm segments and ipc files - the new overload kills the child with SIGKILL after the timeout and logs the timeout in the captured output - keep the old overload (no limit) for compatibility Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.8 KiB
C++
54 lines
1.8 KiB
C++
/********************************************************************************
|
|
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
|
* *
|
|
* This software is distributed under the terms of the *
|
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
|
* copied verbatim in the file "LICENSE" *
|
|
********************************************************************************/
|
|
|
|
#ifndef FAIR_MQ_TOOLS_PROCESS_H
|
|
#define FAIR_MQ_TOOLS_PROCESS_H
|
|
|
|
#include <chrono>
|
|
#include <string>
|
|
|
|
namespace fair::mq::tools
|
|
{
|
|
|
|
/**
|
|
* Result type for execute function. Holds captured stdout output and exit code.
|
|
*/
|
|
struct execute_result
|
|
{
|
|
std::string console_out;
|
|
int exit_code;
|
|
};
|
|
|
|
/**
|
|
* Execute given command in forked process and capture stdout output
|
|
* and exit code.
|
|
*
|
|
* @param[in] cmd Command to execute
|
|
* @param[in] prefix How to prefix each captured output line with
|
|
* @param[in] input Data which is sent to stdin of the child process
|
|
* @return Captured stdout output and exit code
|
|
*/
|
|
execute_result execute(const std::string& cmd,
|
|
const std::string& prefix = "",
|
|
const std::string& input = "",
|
|
int sig = -1);
|
|
|
|
/**
|
|
* Same as above, but kill the child process (SIGKILL) if it runs longer than
|
|
* timeout. A timeout of zero means no limit.
|
|
*/
|
|
execute_result execute(const std::string& cmd,
|
|
const std::string& prefix,
|
|
const std::string& input,
|
|
int sig,
|
|
std::chrono::milliseconds timeout);
|
|
|
|
} // namespace fair::mq::tools
|
|
|
|
#endif /* FAIR_MQ_TOOLS_PROCESS_H */
|