browsermob-proxy icon indicating copy to clipboard operation
browsermob-proxy copied to clipboard

Forward SIGTERM and SIGINT down to java process in wrapper script

Open sake opened this issue 4 years ago • 0 comments

This patch adds trap handlers to the sh wrapper script, so that the Java process terminates when the sh process receives either SIGTERM or SIGINT.

I observed that the Java process kept running when the wrapper process gets killed by Ctrl-C or a signal sent over another way. The trap handler makes sure that it forwards the signal to the Java child process, which does not happen otherwise in sh compatible shells.

The only drawback I see is that SIGKILL is not handled as it is not possible to intercept it. As the python lib (https://github.com/AutomatedTester/browsermob-proxy-py) is using SIGKILL this unfortunately does not solve the problem there (https://github.com/AutomatedTester/browsermob-proxy-py/issues/76).

An even simpler solution would be to just run the Java process with exec. However in that case the JAVACMD check would have to happen before and it would need to be made without invoking the browsermod-proxy code. So I decided that this would change less in the script. I am happy to provide an alternative version if that is desireable.

sake avatar May 07 '21 17:05 sake