获取 Ruby 以识别子进程是否出现段错误

Get Ruby to identify if child process get a segfault

我 运行 Ruby 作为 EDA 工具的包装器,在 RH5 中。
该工具出现段错误。但是,命令行没有显示任何指示。只有当 运行 Ruby 启动的命令时,我们才知道发生了段错误。如何在包装器中获取段错误消息? 谢谢

来自Kernel#system documentation

system returns true if the command gives zero exit status, false for non zero exit status. Returns nil if command execution fails. An error status is available in $?.

因此,如果您只想确保一切正常,只需检查 system 的 return 值是否为 true。如果你想专门检查是否有段错误,那么 return 值将是 false$: 将是这样的:

puts $?
#=> pid 3658 SIGSEGV (signal 11)