문제

I'm using Node.js and am piping the buffer to the response in the browser using node.js. I want to be able to kill the spawn however, once that pipe has broken or if the user disconnects. Is there a way to do this?

Thank you!

도움이 되었습니까?

해결책

All you have to do here is attach a handler for the stream's end event. Once that is fired, you can kill your spawned process.

If this sub-process is something you wrote (such as in Node.js), you can have the process kill itself. Otherwise, just have the same chunk of code that spawns it in the first place add a handler for end, and kill it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top