Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

44 lines
1.0KB

  1. /*
  2. * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
  3. *
  4. * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
  5. *
  6. * Use of this source code is governed by MIT license that can be found in the
  7. * LICENSE file in the root of the source tree. All contributing project authors
  8. * may be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef ZLMEDIAKIT_PROCESS_H
  11. #define ZLMEDIAKIT_PROCESS_H
  12. #if defined(_WIN32)
  13. #if !defined(__MINGW32__)
  14. typedef int pid_t;
  15. #endif
  16. #else
  17. #include <sys/wait.h>
  18. #endif // _WIN32
  19. #include <fcntl.h>
  20. #include <string>
  21. class Process {
  22. public:
  23. Process();
  24. ~Process();
  25. void run(const std::string &cmd, std::string &log_file);
  26. void kill(int max_delay,bool force = false);
  27. bool wait(bool block = true);
  28. int exit_code();
  29. private:
  30. int _exit_code = 0;
  31. pid_t _pid = -1;
  32. void *_handle = nullptr;
  33. #if (defined(__linux) || defined(__linux__))
  34. void *_process_stack = nullptr;
  35. #endif
  36. };
  37. #endif //ZLMEDIAKIT_PROCESS_H