How to let Rscript behave similar to other linux programs by not generating errors upon SIGPIPE?

可紊 提交于 2019-12-11 13:14:01

问题


Here are some related discussions. But I don't think the answers are relevant to my question.

Piping Rscript gives error after output

Normal linux commands work just fine upon receiving SIGPIPE

$ seq 10 |head -n 1
1

But Rscript behaves differently as shown in the above discussion URL. But littler's r does not have this problem.

Is there a way to make Rscript use the default SIGPIPE handler so that it will have a similar behavior to other linux programs?

Here mentions how to set it a the C level? But is there a way to set so in R code? Thanks.

https://colinfay.me/writing-r-extensions/linking-guis-and-other-front-ends-to-r.html

You may also want to consider how signals are handled: R sets signal handlers for several signals, including SIGINT, SIGSEGV, SIGPIPE, SIGUSR1 and SIGUSR2, but these can all be suppressed by setting the variable R_SignalHandlers (declared in Rinterface.h) to 0.

来源:https://stackoverflow.com/questions/53936141/how-to-let-rscript-behave-similar-to-other-linux-programs-by-not-generating-erro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!