示例#1
0
func write(s serial.Port) {
	for {
		reader := bufio.NewReader(os.Stdin)
		text, _ := reader.ReadString('\n')
		s.Write([]byte(text))
	}
}
示例#2
0
// This functions handles signals to the main process and routes them to the VM
func sigh(s serial.Port) {
	sigchan := make(chan os.Signal, 1)
	signal.Notify(sigchan)

	ascii := map[os.Signal]string{
		syscall.SIGINT:  "\x03",
		syscall.SIGTSTP: "\x1A",
	}

	for sig := range sigchan {
		if val, ok := ascii[sig]; ok {
			s.Write([]byte(val))
		}
	}
}