父进程的输出被子进程阻止

时间:2017-02-15 11:58:30

标签: windows perl system

我通过运行QString::toUtf8 以非阻塞方式打开两个文件(一个是system(1, $file),第二个是.html)。这两个文件打开正常,但在我的代码中执行此步骤之后,当我尝试重命名主进程的输出时,它会失败。我读了this个问题,我认为在Perl中也发生了同样的事情。
在我尝试调试原因时,我将此代码用于子进程:

.xlsm

返回以下输出:

if ($? == -1) {
    print "failed to execute: $!\n";
}
elsif ($? & 127) {
    printf "child died with signal %d, %s coredump\n",
    ($? & 127),  ($? & 128) ? 'with' : 'without';
}
else {
    printf "child exited with value %d\n", $? >> 8;
}

要重命名日志文件,我使用:

child died with signal 12, without coredump
child died with signal 56, with coredump

更新:使用my $file = 'path_to_file'; my $oldLogFile = $file; open LOG, "<".$file or Error('005',$file,__PACKAGE__,$ERRNO); my @log = <LOG>; close LOG; # here i am parsing @log for errors and will set a variable $status acordingly $file =~ s/\.log$/\.$status/; #modify the extension from log to warn, err, ok # Error is a predefined function in one of my modules to format the error message rename ($oldLogFile,$file) or Error('001', "rename", $file, __PACKAGE__, $ERRNO ); #rename the files with new extension 时会重现相同的行为。 我该如何解决这个问题?

0 个答案:

没有答案
相关问题