blob: d5a15d19f2a955c03a4783d26a8f302b87d578a8 [file] [log] [blame]
george.karpenkov29efa6d2017-08-21 23:25:50 +00001//===- FuzzerUtilLinux.cpp - Misc utils for Linux. ------------------------===//
2//
chandlerc40284492019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
george.karpenkov29efa6d2017-08-21 23:25:50 +00006//
7//===----------------------------------------------------------------------===//
8// Misc utils for Linux.
9//===----------------------------------------------------------------------===//
10#include "FuzzerDefs.h"
vitalybuka5f3206d2018-04-09 22:38:26 +000011#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD || \
12 LIBFUZZER_OPENBSD
morehousea80f6452017-12-04 19:25:59 +000013#include "FuzzerCommand.h"
george.karpenkov29efa6d2017-08-21 23:25:50 +000014
15#include <stdlib.h>
kcc243006d2019-02-12 00:12:33 +000016#include <sys/types.h>
17#include <sys/wait.h>
18
george.karpenkov29efa6d2017-08-21 23:25:50 +000019
20namespace fuzzer {
21
morehousea80f6452017-12-04 19:25:59 +000022int ExecuteCommand(const Command &Cmd) {
23 std::string CmdLine = Cmd.toString();
kcc243006d2019-02-12 00:12:33 +000024 int exit_code = system(CmdLine.c_str());
25 if (WIFEXITED(exit_code))
26 return WEXITSTATUS(exit_code);
27 return exit_code;
george.karpenkov29efa6d2017-08-21 23:25:50 +000028}
29
30} // namespace fuzzer
31
vitalybuka5f3206d2018-04-09 22:38:26 +000032#endif