pull/2943/head
winlin 4 years ago
commit 2e8766515e

@ -7,6 +7,10 @@ assignees: ''
--- ---
> 注意不提供以下信息的Issue会被直接删除(Please follow issue template, or we will delete it)
> 注意咨询和讨论请提交到SRS星球(Please ask question at) http://bbs.ossrs.net
**描述(Description)** **描述(Description)**
> 描述你遇到了什么问题(Please description your issue here) > 描述你遇到了什么问题(Please description your issue here)

@ -74,14 +74,15 @@ Other important wiki:
The [TOC(Technical Oversight Committee)](trunk/AUTHORS.md#toc) and [contributors](trunk/AUTHORS.md#contributors): The [TOC(Technical Oversight Committee)](trunk/AUTHORS.md#toc) and [contributors](trunk/AUTHORS.md#contributors):
* [Winlin](https://github.com/winlinvip): All areas of streaming server and documents. * [Winlin](https://github.com/winlinvip): Focus on [issues/PR](https://github.com/ossrs/srs/issues) and tests now.
* [Wenjie](https://github.com/wenjiegit): The focus of his work is on the [HDS](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_DeliveryHDS) module. * [Wenjie](https://github.com/wenjiegit): Focus on [HDS](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_DeliveryHDS) module.
* [Runner365](https://github.com/runner365): The focus of his work is on the [SRT](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_SRTWiki) module. * [Runner365](https://github.com/runner365): Focus on [SRT](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_SRTWiki) module.
* [John](https://github.com/xiaozhihong): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_WebRTC) module. * [HongdaXiao](https://github.com/xiaozhihong): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_WebRTC) module.
* [B.P.Y(Bepartofyou)](https://github.com/Bepartofyou): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_WebRTC) module. * [Bepartofyou](https://github.com/Bepartofyou): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_WebRTC) module.
* [Lixin](https://github.com/xialixin): Focus on [GB28181](https://github.com/ossrs/srs/issues/1500) module. * [XiaLixin](https://github.com/xialixin): Focus on [GB28181](https://github.com/ossrs/srs/issues/1500) module.
* [Mozhan](https://github.com/lipeng19811218): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_WebRTC) module. * [LiPeng](https://github.com/lipeng19811218): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_WebRTC) module.
* [Jinxue](https://github.com/chen-guanghua): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_WebRTC) module. * [ChenGuanghua](https://github.com/chen-guanghua): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_WebRTC) module.
* [HaiboChen](https://github.com/duiniuluantanqin): Focus on [GB28181](https://github.com/ossrs/srs/issues/1500) and [API](https://github.com/ossrs/srs/issues/1657) module.
A big `THANK YOU` also goes to: A big `THANK YOU` also goes to:

@ -153,6 +153,30 @@ srs_error_t srs_redirect_output(string from_file, int to_fd)
return err; return err;
} }
srs_error_t SrsProcess::redirect_io()
{
srs_error_t err = srs_success;
// for the stdout, ignore when not specified.
// redirect stdout to file if possible.
if ((err = srs_redirect_output(stdout_file, STDOUT_FILENO)) != srs_success) {
return srs_error_wrap(err, "redirect stdout");
}
// for the stderr, ignore when not specified.
// redirect stderr to file if possible.
if ((err = srs_redirect_output(stderr_file, STDERR_FILENO)) != srs_success) {
return srs_error_wrap(err, "redirect stderr");
}
// No stdin for process, @bug https://github.com/ossrs/srs/issues/1592
if ((err = srs_redirect_output("/dev/null", STDIN_FILENO)) != srs_success) {
return srs_error_wrap(err, "redirect /dev/null");
}
return err;
}
srs_error_t SrsProcess::start() srs_error_t SrsProcess::start()
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -183,21 +207,10 @@ srs_error_t SrsProcess::start()
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
signal(SIGTERM, SIG_IGN); signal(SIGTERM, SIG_IGN);
// for the stdout, ignore when not specified. // redirect standard I/O, if it failed, output error to stdout, and exit child process.
// redirect stdout to file if possible. if ((err = redirect_io()) != srs_success) {
if ((err = srs_redirect_output(stdout_file, STDOUT_FILENO)) != srs_success) { fprintf(stdout, "child process error, %s\n", srs_error_desc(err).c_str());
return srs_error_wrap(err, "redirect output"); exit(-1);
}
// for the stderr, ignore when not specified.
// redirect stderr to file if possible.
if ((err = srs_redirect_output(stderr_file, STDERR_FILENO)) != srs_success) {
return srs_error_wrap(err, "redirect output");
}
// No stdin for process, @bug https://github.com/ossrs/srs/issues/1592
if ((err = srs_redirect_output("/dev/null", STDIN_FILENO)) != srs_success) {
return srs_error_wrap(err, "redirect input");
} }
// should never close the fd 3+, for it myabe used. // should never close the fd 3+, for it myabe used.

@ -53,6 +53,9 @@ public:
// @param argv the argv for binary path, the argv[0] generally is the binary. // @param argv the argv for binary path, the argv[0] generally is the binary.
// @remark the argv[0] must be the binary. // @remark the argv[0] must be the binary.
virtual srs_error_t initialize(std::string binary, std::vector<std::string> argv); virtual srs_error_t initialize(std::string binary, std::vector<std::string> argv);
private:
// Redirect standard I/O.
virtual srs_error_t redirect_io();
public: public:
// Start the process, ignore when already started. // Start the process, ignore when already started.
virtual srs_error_t start(); virtual srs_error_t start();

Loading…
Cancel
Save