@@ -328,7 +328,7 @@ func spHandlerProgram(flasher string, cmdString []string) error {
328328 return err
329329 }
330330
331- multi := io .MultiReader (stderr , stdout )
331+ // multi := io.MultiReader(stderr, stdout)
332332
333333 // Stdout buffer
334334 //var cmdOutput []byte
@@ -341,16 +341,29 @@ func spHandlerProgram(flasher string, cmdString []string) error {
341341
342342 err = oscmd .Start ()
343343
344- in := bufio .NewScanner (multi )
344+ stdout_copy := bufio .NewScanner (stdout )
345+ stderr_copy := bufio .NewScanner (stderr )
345346
346- in .Split (bufio .ScanLines )
347+ stdout_copy .Split (bufio .ScanLines )
348+ stderr_copy .Split (bufio .ScanLines )
347349
348- for in .Scan () {
349- log .Info (in .Text ())
350- mapD := map [string ]string {"ProgrammerStatus" : "Busy" , "Msg" : in .Text ()}
351- mapB , _ := json .Marshal (mapD )
352- h .broadcastSys <- mapB
353- }
350+ go func () {
351+ for stdout_copy .Scan () {
352+ log .Info (stdout_copy .Text ())
353+ mapD := map [string ]string {"ProgrammerStatus" : "Busy" , "Msg" : stdout_copy .Text ()}
354+ mapB , _ := json .Marshal (mapD )
355+ h .broadcastSys <- mapB
356+ }
357+ }()
358+
359+ go func () {
360+ for stderr_copy .Scan () {
361+ log .Info (stderr_copy .Text ())
362+ mapD := map [string ]string {"ProgrammerStatus" : "Busy" , "Msg" : stderr_copy .Text ()}
363+ mapB , _ := json .Marshal (mapD )
364+ h .broadcastSys <- mapB
365+ }
366+ }()
354367
355368 err = oscmd .Wait ()
356369
0 commit comments