rootlessport: use two different channels
The same channel is written to by two different goroutines.
Use a different channel for each of them so to avoid writing to a
closed channel.
Closes:
@@ -102,19 +102,19 @@ func parent() error {
return err
}
+ exitC := make(chan os.Signal, 1)
+ defer close(exitC)
+
+ go func() {
sigC := make(chan os.Signal, 1)
signal.Notify(sigC, unix.SIGPIPE)
- defer func() {
- // dummy signal to terminate the goroutine
- sigC <- unix.SIGKILL
- }()
- go func() {
defer func() {
signal.Stop(sigC)
close(sigC)
}()
- s := <-sigC
+ select {
+ case s := <-sigC:
if s == unix.SIGPIPE {
if f, err := os.OpenFile("/dev/null", os.O_WRONLY, 0755); err == nil {
unix.Dup2(int(f.Fd()), 1) // nolint:errcheck
@@ -122,6 +122,8 @@ func parent() error {
f.Close()
}
}
+ case <-exitC:
+ }
}()
// create the parent driver
