2014년 12월 4일 목요일

child_process pause/resume

is it possible to set a child_process.fork() on "pause" and later resume it ?

I down´t want the dirty way over a wile loop.



You could send SIGSTOP to the process. This will not work on Windows.

But what are your actual requirements here to stop the process?



I want to sep through my child_process code like a debugger.

I habve try it with the bild in debugger but how can i concrol the debugger from the parent process ?



I want to sep through my child_process code like a debugger.
I read this as "I want to have link between child and parent and control logic of the child".
With child_process.fork() you already have this link, exposed as on('message')and send(message


I habve try it with the bild in debugger but how can i concrol the debugger from the parent process ?

Yes, you can (though I doubt it's a good solution for your problem)

1) spawn your child with debugger enabled 

   var child = spawn('node', ['--debug-brk', 'script.js', 'some', 'params']);

2) connect debugger client from parent:

var DebuggerClient = require('_debugger').Client;
var dc = new DebuggerClient();
dc.connect(5858);
3) add some breakpoints to your script with "debugger" keyword or programmitically with dc.setBreakpoint()
4) drive your it with calls to dc.step(), dc.recContinue() and by reacting on break events:  
dc.on('break', function(resp) { /* your child stopped */ });

댓글 없음:

댓글 쓰기