// run aplaymidi on listed file path.
run aplaymidi on listed file path.
// run aplaymidi on listed file path .
func aplaymidi(midiport string, filename string, quit <-chan struct{}) error {
	Debug.Printf("Playing %s", filename)
	cmd := exec.Command("aplaymidi", "-p", midiport, filename)
	var errbuf bytes.Buffer
	cmd.Stderr = &errbuf
	cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
	err := cmd.Start()
	if err != nil {
		return err
	}
	done := make(chan struct{})
	defer close(done)
	go func() {
		select {
		case <-quit:
			Debug.Println("Forcing aplaymidi to stop")
			cmd.Process.Kill()
		case <-done:
		}
	}()
	e := cmd.Wait()
	if e != nil {
		e = fmt.Errorf("%s: %v", errbuf.String(), e)
	}
	return e
}
func aplaymidi ( midiport string , filename string , quit <- chan struct { } ) error { Debug . Printf ( " " , filename ) cmd := exec . Command ( " " , " " , midiport , filename ) var errbuf bytes . Buffer cmd . Stderr = & errbuf cmd . SysProcAttr = & syscall . SysProcAttr { Setpgid : true } err := cmd . Start ( ) if err != nil { return err } done := make ( chan struct { } ) defer close ( done ) go func ( ) { select { case <- quit : Debug . Println ( " " ) cmd . Process . Kill ( ) case <- done : } } ( ) e := cmd . Wait ( ) if e != nil { e = fmt . Errorf ( " " , errbuf . String ( ) , e ) } return e }
run aplaymidi on listed file path.
run aplaymidi on listed file path .
// prevent Ctrl + C and other signals to get sent // killer goroutine