@@ -33,11 +33,11 @@ function run(options) {
33
33
var stdio = [ 'pipe' , 'pipe' , 'pipe' ] ;
34
34
35
35
if ( config . options . stdout ) {
36
- stdio = [ 'pipe' , process . stdout , 'pipe' ] ;
36
+ stdio = [ 'pipe' , process . stdout , process . stderr ] ;
37
37
}
38
38
39
39
if ( config . options . stdin === false ) {
40
- stdio = [ process . stdin , process . stdout , 'pipe' ] ;
40
+ stdio = [ process . stdin , process . stdout , process . stderr ] ;
41
41
}
42
42
43
43
var sh = 'sh' ;
@@ -99,6 +99,8 @@ function run(options) {
99
99
if ( shouldFork ) {
100
100
var forkArgs = cmd . args . slice ( 1 ) ;
101
101
var env = utils . merge ( options . execOptions . env , process . env ) ;
102
+ stdio . pop ( ) ;
103
+ stdio . push ( process . stderr ) ;
102
104
stdio . push ( 'ipc' ) ;
103
105
child = fork ( options . execOptions . script , forkArgs , {
104
106
env : env ,
@@ -110,7 +112,7 @@ function run(options) {
110
112
} else {
111
113
utils . log . detail ( 'spawning' ) ;
112
114
child = spawn . apply ( null , spawnArgs ) ;
113
- debug ( 'spawn' , sh , shFlag , args )
115
+ debug ( 'spawn' , sh , shFlag , args ) ;
114
116
}
115
117
116
118
if ( config . required ) {
@@ -139,20 +141,6 @@ function run(options) {
139
141
bus . emit ( 'message' , message , sendHandle ) ;
140
142
} ) ;
141
143
}
142
- } else { // else if not required…
143
-
144
- // this swallows a shell message that happens because we kill the sh -c
145
- // more details here: https://git.io/Je6d0
146
- child . stderr . on ( 'data' , s => {
147
- s = s . toString ( ) ;
148
-
149
- if ( child . __nodemonRestart ) { // this flag is set right before the kill
150
- utils . log . detail ( 'stderr: ' + s ) ;
151
- return ;
152
- }
153
-
154
- process . stderr . write ( s ) ;
155
- } ) ;
156
144
}
157
145
158
146
bus . emit ( 'start' ) ;
@@ -276,7 +264,6 @@ function run(options) {
276
264
/* Now kill the entire subtree of processes belonging to nodemon */
277
265
var oldPid = child . pid ;
278
266
if ( child ) {
279
- child . __nodemonRestart = true ;
280
267
kill ( child , config . signal , function ( ) {
281
268
// this seems to fix the 0.11.x issue with the "rs" restart command,
282
269
// though I'm unsure why. it seems like more data is streamed in to
@@ -380,6 +367,8 @@ function kill(child, signal, callback) {
380
367
// the sub processes need to be killed from smallest to largest
381
368
debug ( 'sending kill signal to ' + pids . join ( ', ' ) ) ;
382
369
370
+ child . kill ( signal ) ;
371
+
383
372
pids . sort ( ) . forEach ( pid => exec ( `kill -${ sig } ${ pid } ` , noop ) ) ;
384
373
385
374
waitForSubProcesses ( child . pid , ( ) => {
0 commit comments