george.karpenkov | 29efa6d | 2017-08-21 23:25:50 +0000 | [diff] [blame] | 1 | //===- FuzzerUtilLinux.cpp - Misc utils for Linux. ------------------------===// |
| 2 | // |
chandlerc | 4028449 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // 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.karpenkov | 29efa6d | 2017-08-21 23:25:50 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // Misc utils for Linux. |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | #include "FuzzerDefs.h" |
vitalybuka | 5f3206d | 2018-04-09 22:38:26 +0000 | [diff] [blame] | 11 | #if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD || \ |
| 12 | LIBFUZZER_OPENBSD |
morehouse | a80f645 | 2017-12-04 19:25:59 +0000 | [diff] [blame] | 13 | #include "FuzzerCommand.h" |
george.karpenkov | 29efa6d | 2017-08-21 23:25:50 +0000 | [diff] [blame] | 14 | |
| 15 | #include <stdlib.h> |
kcc | 243006d | 2019-02-12 00:12:33 +0000 | [diff] [blame^] | 16 | #include <sys/types.h> |
| 17 | #include <sys/wait.h> |
| 18 | |
george.karpenkov | 29efa6d | 2017-08-21 23:25:50 +0000 | [diff] [blame] | 19 | |
| 20 | namespace fuzzer { |
| 21 | |
morehouse | a80f645 | 2017-12-04 19:25:59 +0000 | [diff] [blame] | 22 | int ExecuteCommand(const Command &Cmd) { |
| 23 | std::string CmdLine = Cmd.toString(); |
kcc | 243006d | 2019-02-12 00:12:33 +0000 | [diff] [blame^] | 24 | int exit_code = system(CmdLine.c_str()); |
| 25 | if (WIFEXITED(exit_code)) |
| 26 | return WEXITSTATUS(exit_code); |
| 27 | return exit_code; |
george.karpenkov | 29efa6d | 2017-08-21 23:25:50 +0000 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | } // namespace fuzzer |
| 31 | |
vitalybuka | 5f3206d | 2018-04-09 22:38:26 +0000 | [diff] [blame] | 32 | #endif |