简体   繁体   English

命令与shell一起运行,但卡在QProcess中

[英]Command run with shell but get stuck with QProcess

I'm trying to execute some command with QProcess. 我正在尝试使用QProcess执行一些命令。 Executing from terminal works fine. 从终端执行工作正常。

For example, I want to execute following command: fpscan /path --report --verbose=2 --nospin (scanning files with f-prot antivirus). 例如,我想执行以下命令: fpscan /path --report --verbose=2 --nospin (使用f-prot防病毒扫描文件)。 I'm trying the following code: 我正在尝试以下代码:

QProcess* p = new QProcess(this);
p->start("fpscan", params);

process get stuck. 过程卡住了。

From ps -Al | grep fpscan 来自ps -Al | grep fpscan ps -Al | grep fpscan output I see, that this process opens another process. 我看到ps -Al | grep fpscan输出,这个进程打开另一个进程。

process     |    WCHAN    |    TIME
1           |    wait     |  00:00:00
2           |    pipe_w   |  00:00:00

strace command: strace命令:

  1. wait4(-1, wait4(-1,
  2. read(0, 阅读(0,

Any suggestions? 有什么建议么?

PS: another command clamscan /path params works fine with QProcess. PS:另一个命令clamscan /path params适用于QProcess。

Update: I've tried to use fork, execl, and it works, so the problem is with QT and QProcess. 更新:我尝试使用fork,execl,它可以工作,所以问题出在QT和QProcess上。

pid_t pid = fork();
if (pid == 0) {
    execl("/usr/local/bin/fpscan", "fpscan", "/path", ... , NULL);
}

看起来这个过程试图从stdin读取。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM