Frage

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!

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top