bash php沉默segfault [英] bash php silence segfault

查看:103
本文介绍了bash php沉默segfault的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要阻止所有php输出, https://stackoverflow.com/a/617184/1695680 涵盖了如何总体上可以做到这一点,并且到目前为止,它仍然可以解决异常,语法错误等问题.

I need to prevent all php output, https://stackoverflow.com/a/617184/1695680 covers how to do this in general and for exception, errors, syntax errors so far it has worked, but.

php在pcre扩展中产生段错误: https://ilia.ws/archives/5_Top_10_ways_to_crash_PHP.html

php to produce a segfault in the pcre extension: https://ilia.ws/archives/5_Top_10_ways_to_crash_PHP.html

<?php
# prce-bug.php

preg_match('/(.(?!b))*/', str_repeat("a", 10000));

在我的测试中,这仍然输出:

In my testing, this still outputs:

user@host ~/crash-php $ php pcre-bug.php 
Segmentation fault (core dumped)

user@host ~/crash-php $ php pcre-bug.php  >/dev/null 2>&1
Segmentation fault (core dumped)

因此,即使使用shell输出重定向,输出也将到达我的终端.

So even with shell output redirection, output is getting to my terminal.

推荐答案

我发现使用新的sh shell实例将捕获系统报告的进程死亡,例如Segmentation Fault和Killed.

I found that using a new sh shell instance will capture system reported process deaths, like Segmentation Fault and Killed.

sh -c 'php pcre-bug.php' >/dev/null 2>&1

但是,输入参数不会传递给php,而是传递给与它们无关的sh实例.

However, input arguments do not go to php, but rather to the sh instance which does nothing with them.

这篇关于bash php沉默segfault的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆