@@ -70,14 +70,27 @@ const getChiaVersion = () => {
70
70
const startChiaDaemon = ( ) => {
71
71
const script = getScriptPath ( PY_DIST_FILE ) ;
72
72
const processOptions = { } ;
73
- // processOptions.detached = true;
74
- // processOptions.stdio = "ignore";
73
+ // We want to detach child daemon process from parent GUI process.
74
+ // You may think `detached: true` will do but it shows blank terminal on Windows.
75
+ // In order to hide the blank terminal while detaching child process,
76
+ // {detached: false, windowsHide: false, shell: true} works which is exact opposite of what we expect
77
+ // Please see the comment below for more details.
78
+ // https://github.com/nodejs/node/issues/21825#issuecomment-503766781
79
+ processOptions . detached = false ;
80
+ processOptions . stdio = 'ignore' ;
81
+ processOptions . windowsHide = false ;
82
+ processOptions . shell = true ;
75
83
pyProc = null ;
76
84
if ( guessPackaged ( ) ) {
77
85
try {
78
86
console . info ( 'Running python executable: ' ) ;
79
- const Process = childProcess . spawn ;
80
- pyProc = new Process ( script , [ '--wait-for-unlock' ] , processOptions ) ;
87
+ if ( processOptions . stdio === 'ignore' ) {
88
+ const subProcess = childProcess . spawn ( script , [ '--wait-for-unlock' ] , processOptions ) ;
89
+ subProcess . unref ( ) ;
90
+ } else {
91
+ const Process = childProcess . spawn ;
92
+ pyProc = new Process ( script , [ '--wait-for-unlock' ] , processOptions ) ;
93
+ }
81
94
} catch ( e ) {
82
95
console . info ( 'Running python executable: Error: ' ) ;
83
96
console . info ( `Script ${ script } ` ) ;
@@ -86,10 +99,15 @@ const startChiaDaemon = () => {
86
99
console . info ( 'Running python script' ) ;
87
100
console . info ( `Script ${ script } ` ) ;
88
101
89
- const Process = childProcess . spawn ;
90
- pyProc = new Process ( 'python' , [ script , '--wait-for-unlock' ] , processOptions ) ;
102
+ if ( processOptions . stdio === 'ignore' ) {
103
+ const subProcess = childProcess . spawn ( 'python' , [ script , '--wait-for-unlock' ] , processOptions ) ;
104
+ subProcess . unref ( ) ;
105
+ } else {
106
+ const Process = childProcess . spawn ;
107
+ pyProc = new Process ( 'python' , [ script , '--wait-for-unlock' ] , processOptions ) ;
108
+ }
91
109
}
92
- if ( pyProc != null ) {
110
+ if ( pyProc != null && processOptions . stdio !== 'ignore' ) {
93
111
pyProc . stdout . setEncoding ( 'utf8' ) ;
94
112
95
113
pyProc . stdout . on ( 'data' , ( data ) => {
0 commit comments