Process.h 1.01 KB
Newer Older
1
/*
xiongziliang committed
2
 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
xiongziliang committed
3
 *
4
 * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
xiongziliang committed
5
 *
xiongziliang committed
6 7 8
 * 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.
xiongziliang committed
9
 */
xiongziliang committed
10

11 12
#ifndef ZLMEDIAKIT_PROCESS_H
#define ZLMEDIAKIT_PROCESS_H
13

monktan89 committed
14 15
#if defined(_WIN32)
#if !defined(__MINGW32__)
16
typedef int pid_t;
monktan89 committed
17
#endif
18
#else
19
#include <sys/wait.h>
20 21
#endif // _WIN32

22
#include <fcntl.h>
23 24 25 26 27 28
#include <string>

class Process {
public:
    Process();
    ~Process();
29
    void run(const std::string &cmd, std::string &log_file);
30
    void kill(int max_delay,bool force = false);
31 32 33
    bool wait(bool block = true);
    int exit_code();
private:
34
    int _exit_code = 0;
35
    pid_t _pid = -1;
xiongziliang committed
36
    void *_handle = nullptr;
37 38 39
#if (defined(__linux) || defined(__linux__))
    void *_process_stack = nullptr;
#endif
40 41 42
};


43
#endif //ZLMEDIAKIT_PROCESS_H