我使用child_process.exec()api来执行带有超时选项的C ++问题:
child_process.exec('main.cpp', {timeout: 1000}, callback)
超时后,child_process调用回调函数时出错,但是当我再次尝试运行#include <iostream>
using namespace std;
int main () {
while(1);
return 0;
}
时,我收到错误,说主程序仍在运行。
如何在超时后停止main.exe?
以下是main.cpp代码:
<?php
// Template Name: Blog
get_header(); ?>
<div id="primary" class="content-area">
<section id="main" class="site-main blog" role="main">
<div class="container">
<div class="row">
<div class="col-lg-9 col-xs-12">
<?php $args = array(
'post_type' => 'post'
);
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
while($post_query->have_posts() ) {
$post_query->the_post(); ?>
<?php get_template_part('template-parts/content-blog', 'none'); ?>
<?php
}
} ?>
</div>
<div class="col-lg-3 col-xs-12">
<?php dynamic_sidebar( 'blog_sidebar' ); ?>
</div>
</div>
</div>
</section><!-- #main -->
</div><!-- #primary -->
<?php get_footer();