从perl脚本调用unoconv时设备的ioctl不正确

从perl脚本调用unoconv时设备的ioctl不正确,perl,postfix-mta,document-conversion,Perl,Postfix Mta,Document Conversion,每次收到指定域的电子邮件时,我都会从postfix电子邮件服务器触发一个perl脚本。perl脚本基本上提取所有附件,然后调用unoconv将附件转换为PDF格式 我目前正在测试脚本,总是使用相同的电子邮件和相同的附件,我看到一个随机行为。有时会转换所有附件,有时会在调用unoconv命令时出现错误“设备的ioctl不适当”,如: unoconv -f pdf -o /tmp/2151DC80-A545-11E4-880B-D7DC6512523E/ '/tmp/2151DC80-A545-11

每次收到指定域的电子邮件时,我都会从postfix电子邮件服务器触发一个perl脚本。perl脚本基本上提取所有附件,然后调用unoconv将附件转换为PDF格式

我目前正在测试脚本,总是使用相同的电子邮件和相同的附件,我看到一个随机行为。有时会转换所有附件,有时会在调用unoconv命令时出现错误“设备的ioctl不适当”,如:

unoconv -f pdf -o /tmp/2151DC80-A545-11E4-880B-D7DC6512523E/ '/tmp/2151DC80-A545-11E4-880B-D7DC6512523E/attachments/21887524-A545-11E4-880B-D7DC6512523E-test.doc'
看起来像是赛车状况问题或类似问题。有什么问题吗

更新:问题似乎是unoconv有时会以浮点异常退出,但文档已成功转换(我可以在PDF查看器中打开它)。这里是出现错误的函数的代码。现在的问题是如何处理这种情况

################################################################################
#                       Convert attachments to PDF                             #
################################################################################
sub convertAttachments() {
  $logger->info("converting attachments");
  mkdir  $email_converted_attachment_dir;

  opendir(DIR, $email_attachment_dir) or die $!;
    while (my $file = readdir(DIR)) {
        next if ($file =~ m/^\./);
        $logger->info("Converting attachment: ".$email_attachment_dir.$file);
        $conv_result = "unoconv -v -T 10 -f pdf -o ".$email_converted_attachment_dir." '".$email_attachment_dir.$file."'";
        $logger->info("Running Command: ".$conv_result);
        system($conv_result) and die  "Can't launch unoconv: $!";
    }
  closedir(DIR);
}
曼努科诺夫说:

unoconv uses the LibreOffice’s UNO bindings for non-interactive
   conversion of documents and therefore needs an LibreOffice instance to
   communicate with. Therefore if it cannot find one, it will start its
   own instance for temporary usage. If desired, one can start a
   “listener” instance to use for subsequent connections or even for
   remote connections.


继续给我们一个关于代码实际在做什么的提示。
-T, --timeout
       When unoconv starts its own listener, try to connect to it for an
       amount of seconds before giving up. Increasing this may help when
       you receive random errors caused by the listener not being ready to
       accept conversion jobs.