本文整理汇总了C++中ShellExecContext::exit方法的典型用法代码示例。如果您正苦于以下问题:C++ ShellExecContext::exit方法的具体用法?C++ ShellExecContext::exit怎么用?C++ ShellExecContext::exit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShellExecContext
的用法示例。
在下文中一共展示了ShellExecContext::exit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HHVM_FUNCTION
String HHVM_FUNCTION(exec,
const String& command,
VRefParam output /* = null */,
VRefParam return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command);
if (!fp) return empty_string();
StringBuffer sbuf;
sbuf.read(fp);
Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
int ret = ctx.exit();
if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
return_var = ret;
int count = lines.size();
if (count > 0 && lines[count - 1].toString().empty()) {
count--; // remove explode()'s last empty line
}
PackedArrayInit pai(count);
for (int i = 0; i < count; i++) {
pai.append(lines[i]);
}
output.wrapped() = pai.toArray();
if (!count || lines.empty()) {
return String();
}
return HHVM_FN(rtrim)(lines[count - 1].toString());
}
示例2: f_exec
String f_exec(const String& command, VRefParam output /* = null */,
VRefParam return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command.c_str());
if (!fp) return "";
StringBuffer sbuf;
sbuf.read(fp);
Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
int ret = ctx.exit();
if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
return_var = ret;
int count = lines.size();
if (count > 0 && lines[count - 1].toString().empty()) {
count--; // remove explode()'s last empty line
}
if (!output.is(KindOfArray)) {
output = Array(ArrayData::Create());
}
for (int i = 0; i < count; i++) {
output.append(lines[i]);
}
if (!count || lines.empty()) {
return String();
}
return f_rtrim(lines[count - 1].toString());
}
示例3: f_system
String f_system(const String& command, VRefParam return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command.c_str());
if (!fp) return "";
StringBuffer sbuf;
if (fp) {
sbuf.read(fp);
}
Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
int ret = ctx.exit();
if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
return_var = ret;
int count = lines.size();
if (count > 0 && lines[count - 1].toString().empty()) {
count--; // remove explode()'s last empty line
}
for (int i = 0; i < count; i++) {
echo(lines[i].toString());
echo("\n");
}
if (!count || lines.empty()) {
return String();
}
return f_rtrim(lines[count - 1].toString());
}
示例4: f_system
String f_system(CStrRef command, Variant return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command);
if (!fp) return "";
StringBuffer sbuf;
if (fp) {
sbuf.read(fp);
}
Array lines = StringUtil::Explode(sbuf.detach(), "\n");
return_var = ctx.exit();
int count = lines.size();
if (count > 0 && lines[count - 1].toString().empty()) {
count--; // remove explode()'s last empty line
}
for (int i = 0; i < count; i++) {
echo(lines[i]);
echo("\n");
}
if (!count || lines.empty()) {
return String();
}
return StringUtil::Trim(lines[count - 1], StringUtil::TrimRight);
}
示例5: f_exec
String f_exec(CStrRef command, Variant output /* = null */,
Variant return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command);
if (!fp) return "";
StringBuffer sbuf;
sbuf.read(fp);
Array lines = StringUtil::Explode(sbuf.detach(), "\n");
return_var = ctx.exit();
int count = lines.size();
if (count > 0 && lines[count - 1].toString().empty()) {
count--; // remove explode()'s last empty line
}
if (!output.is(KindOfArray)) {
output = Array(ArrayData::Create());
}
for (int i = 0; i < count; i++) {
output.append(lines[i]);
}
if (!count || lines.empty()) {
return String();
}
return StringUtil::Trim(lines[count - 1], StringUtil::TrimRight);
}
示例6: f_passthru
void f_passthru(CStrRef command, Variant return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command);
if (!fp) return;
char buffer[1024];
while (true) {
int len = read(fileno(fp), buffer, sizeof(buffer) - 1);
if (len == -1 && errno == EINTR) continue;
if (len <= 0) break; // break on error or EOF
buffer[len] = '\0';
echo(String(buffer, len, AttachLiteral));
}
return_var = ctx.exit();
}
示例7: f_passthru
void f_passthru(const String& command, VRefParam return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command.c_str());
if (!fp) return;
char buffer[1024];
while (true) {
int len = read(fileno(fp), buffer, sizeof(buffer) - 1);
if (len == -1 && errno == EINTR) continue;
if (len <= 0) break; // break on error or EOF
buffer[len] = '\0';
echo(String(buffer, len, CopyString));
}
int ret = ctx.exit();
if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
return_var = ret;
}
示例8: HHVM_FUNCTION
void HHVM_FUNCTION(passthru,
const String& command,
VRefParam return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command);
if (!fp) return;
char buffer[1024];
while (true) {
int len = read(fileno(fp), buffer, sizeof(buffer) - 1);
if (len == -1 && errno == EINTR) continue;
if (len <= 0) break; // break on error or EOF
buffer[len] = '\0';
g_context->write(String(buffer, len, CopyString));
}
int ret = ctx.exit();
MAYBE_WIFEXITED(ret);
return_var.assignIfRef(ret);
}