2020-01-07 15:10:59 +08:00
|
|
|
|
/*
|
2020-04-04 20:30:09 +08:00
|
|
|
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
2019-06-11 09:25:54 +08:00
|
|
|
|
*
|
2021-01-17 18:31:50 +08:00
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
2019-06-11 09:25:54 +08:00
|
|
|
|
*
|
2020-04-04 20:30:09 +08:00
|
|
|
|
* Use of this source code is governed by MIT license that can be found in the
|
|
|
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
|
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
2019-06-11 09:25:54 +08:00
|
|
|
|
*/
|
2020-04-04 20:30:09 +08:00
|
|
|
|
|
2020-01-07 14:37:18 +08:00
|
|
|
|
#ifndef ZLMEDIAKIT_PROCESS_H
|
|
|
|
|
#define ZLMEDIAKIT_PROCESS_H
|
2019-05-20 11:22:59 +08:00
|
|
|
|
|
2020-01-07 14:37:18 +08:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
typedef int pid_t;
|
|
|
|
|
#else
|
2019-05-20 11:22:59 +08:00
|
|
|
|
#include <sys/wait.h>
|
2020-01-07 14:37:18 +08:00
|
|
|
|
#endif // _WIN32
|
|
|
|
|
|
2019-09-27 09:58:42 +08:00
|
|
|
|
#include <fcntl.h>
|
2019-05-20 11:22:59 +08:00
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
class Process {
|
|
|
|
|
public:
|
|
|
|
|
Process();
|
|
|
|
|
~Process();
|
2022-02-02 20:34:50 +08:00
|
|
|
|
void run(const std::string &cmd,const std::string &log_file);
|
2019-10-24 11:42:39 +08:00
|
|
|
|
void kill(int max_delay,bool force = false);
|
2019-05-20 11:22:59 +08:00
|
|
|
|
bool wait(bool block = true);
|
|
|
|
|
int exit_code();
|
|
|
|
|
private:
|
|
|
|
|
pid_t _pid = -1;
|
2020-06-08 16:26:55 +08:00
|
|
|
|
void *_handle = nullptr;
|
2019-05-20 11:22:59 +08:00
|
|
|
|
int _exit_code = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2020-01-07 14:37:18 +08:00
|
|
|
|
#endif //ZLMEDIAKIT_PROCESS_H
|