Most elegant way to terminate straced program

I want to capture a certain thing with strace and then immediately exit. This way the program stays alive: strace ... program 2>&1 | grep --line-buffered ... | read line.

Is there a simple way to make strace kill the program after strace itself is terminated?

This is how I workaround it:

But it doesn't look very nice.

UPD:

Turned out that the actual problem is that the program I trace ignores SIGPIPE. I guess clean way to workaround this is to create an additional layer that intercepts SIGPIPE and sends SIGTERM instead.

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论