Mcafee 递归调用java.lang.Process时挂起

Mcafee 递归调用java.lang.Process时挂起,mcafee,Mcafee,我的程序递归调用McAfee OnDemad Virusscanner以获取特定路径。在一个循环中,我用几个文件填充路径,扫描它,删除文件,填充它,等等。 过了一会儿,程序突然挂起,我不知道原因 Calendar cl = Calendar.getInstance(); String cmd="uvscan -v /var/tmp/McAfee/scanFiles/" try { long start=cl.getTimeIn

我的程序递归调用McAfee OnDemad Virusscanner以获取特定路径。在一个循环中,我用几个文件填充路径,扫描它,删除文件,填充它,等等。 过了一会儿,程序突然挂起,我不知道原因

        Calendar cl = Calendar.getInstance();
        String cmd="uvscan -v /var/tmp/McAfee/scanFiles/"
        try {   
        long start=cl.getTimeInMillis();
        process = Runtime.getRuntime().exec(cmd, null);
        Worker worker = new Worker(process);
        worker.start(); 
        try {
            LOGGER.debug("Virusscan timeout set to {}ms", timeout);
            worker.join(timeout);
            if (worker.exit != null)
                workerRC=worker.exit;
            else {
                cl = Calendar.getInstance();
                long waitTime=cl.getTimeInMillis()-start;
                throw new TimeoutException("Virusscan timeout after " + waitTime + "ms"); 
            }
            //      else
            //          throw new TimeoutException();
        } catch(InterruptedException ex) {
            worker.interrupt();
            Thread.currentThread().interrupt();
            cl = Calendar.getInstance();
            long waitTime=cl.getTimeInMillis()-start;
            throw new TimeoutException("Virusscan timeout after " + waitTime + "ms"); 
        } 

        File scanLog = new File(ConfigReader.getScanLog());
        if (!ConfigReader.mustKeepScanLog()) scanLog.deleteOnExit();
        LOGGER.debug("ScanLog is: " + scanLog.getPath() + " - RC=" + workerRC);
        BufferedWriter bw = new BufferedWriter(new FileWriter(scanLog));
        BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
        // read the output from the command             
        while ((buffer = stdInput.readLine()) != null) {
            inspectScanlog(buffer, workerRC);
            bw.write(buffer+"\n");
            LOGGER.debug("Scan STDOUT: " + buffer);
        }
        BufferedReader stdErr = new BufferedReader(new InputStreamReader(process.getErrorStream()));
        while ((buffer = stdErr.readLine()) != null) {
            LOGGER.debug("Scan STDERR: " + buffer);
        }

        bw.close();

        cl = Calendar.getInstance();
        long waitTime=cl.getTimeInMillis()-start;
        LOGGER.info("Virusscan took " + waitTime + "ms");
        if (workerRC != 0){
            int cc=12;
            ConfigReader.setMaxCC(cc);
            LOGGER.error("RC={} - Virusscan ended with error. CMD=",cc, cmd);
            if (workerRC==13) {
                LOGGER.error("RC={} - The scanner found one or more viruses or hostile objects - such as a Trojan-horse program, joke program, or test file.", cc);
            }
        }
    }
    catch (Exception e) {
        int cc=12;
        ConfigReader.setMaxCC(cc);
        LOGGER.error("RC={} - {}",cc, e.getMessage());
        e.printStackTrace();
    } finally {
        if (process!=null) {
            process.destroy(); 
        }
    }
这看起来像是整个计划的一个悬念;即使超时(240000毫秒)也不匹配。GC日志似乎有点中断:

258.070:[完整GC[PSYoungGen:13456K->7362K(85120K)][PSOldGen:59271K->60735K(81728K)]72727K->68098K(166848K)[PSPermGen:16282K->16282K(30400K)],0.3019290秒][次:用户=0.31系统=0.00,实际=0.31秒] 264.208:[GC[PSYoungGen:65466K->8773K(92224K)]126202K->69581K(173952K),0.0528360秒][次:用户=0.10系统=0.00,实际=0.05秒] 265.445:[GC[PSYoungGen:81774K->9133K(92096K)]142582K->70061K(173824K),0.0205430秒][次:用户=0.03系统=0.00,实数=0.02秒] 266.916:[GC[PSYoungGen:82515K->9698K(100096K)]143443K->70658K(181824K),0.0189050秒][次:用户=0.04系统=0.00,实数=0.02秒] 267.817:[GC[PSYoungGen:92311K->1436K(100480K)]153271K->70986K(182208K),0.0210400秒][次:user=0.03 sys=0.01,real=0.02秒] 274.208:[GC[PSYoungGen:84072K->672K(112256K)]153622K->71297K(193984K),0.0029610秒][次:用户=0.00系统=0.00,实数=0.00秒] 275.769:[GC[PSYoungGen:94880K->500K(112832K)]165505K->71732K(194560K),0.0022440秒]

程序启动后277.609秒调用了uvscan命令

有人能建议一下如何找到绞刑的原因吗

提前感谢,,
Ulrich

worker.start()。。。worker.join()。。。在读取进程之前。在创建stdInput之前它是否挂起?我不确定什么是类工作者,但调用外部进程使进程挂起时,这是一个非常常见的错误,因为该进程的stdout/stderr没有在正确的位置被耗尽。很抱歉,现在已经解决了。我以更短的超时时间运行程序,并查看返回的消息。这就是问题所在。详细模式(-v)和消息flood导致挂起。删除详细模式解决了这个问题。虽然只有3000个文件,但这是预期的消息数乘以100字节,总大小为300KB,这并不多。我会考虑一下给出的提示。非常感谢,乌尔里奇