Skip to content

Commit 7b80333

Browse files
author
githubnemo
committed
Clarify some code
1 parent fb73d5e commit 7b80333

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

daemon.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,14 @@ func runner(commandTemplate string, buildStarted <-chan string, buildSuccess <-c
262262

263263
go logger(pipeChan)
264264

265+
// Launch concurrent process watching for signals from outside that
266+
// indicate termination to kill the running process alongside
267+
// CompileDaemon to prevent orphan processes.
265268
go func() {
266-
sigChan := make(chan os.Signal, 1)
267-
signal.Notify(sigChan, fatalSignals...)
268-
<-sigChan
269+
processSignalChannel := make(chan os.Signal, 1)
270+
signal.Notify(processSignalChannel, fatalSignals...)
271+
<-processSignalChannel
272+
269273
log.Println(okColor("Received signal, terminating cleanly."))
270274
if currentProcess != nil {
271275
killProcess(currentProcess)
@@ -276,8 +280,8 @@ func runner(commandTemplate string, buildStarted <-chan string, buildSuccess <-c
276280
for {
277281
eventPath := <-buildStarted
278282

279-
// append %0.s to use format specifier even if not supplied by user
280-
// to suppress warning in returned string.
283+
// prepend %0.s (which adds nothing) to prevent warning about missing
284+
// format specifier if the user did not supply one.
281285
command := fmt.Sprintf("%0.s"+commandTemplate, eventPath)
282286

283287
if !*flagCommandStop {
@@ -289,6 +293,7 @@ func runner(commandTemplate string, buildStarted <-chan string, buildSuccess <-c
289293
if currentProcess != nil {
290294
killProcess(currentProcess)
291295
}
296+
292297
if *flagCommandStop {
293298
log.Println(okColor("Command stopped. Waiting for build to complete."))
294299
if !<-buildSuccess {

0 commit comments

Comments
 (0)