Fix sff panic deadlock, share the evdev probe, assorted review cleanups
This commit is contained in:
+21
-3
@@ -46,6 +46,7 @@ func main() {
|
||||
}
|
||||
|
||||
restoreTerm := rawKeys()
|
||||
go relayStdin()
|
||||
|
||||
var err error
|
||||
if *fuzzN > 0 {
|
||||
@@ -84,6 +85,26 @@ func rawKeys() func() {
|
||||
return func() { unix.IoctlSetTermios(fd, unix.TCSETS, &saved) }
|
||||
}
|
||||
|
||||
// The child's own process group makes the tty off limits to it (reading from
|
||||
// the background raises SIGTTIN), so the harness reads and forwards to the
|
||||
// run that currently owns the console. One reader for the life of the
|
||||
// process: a copier per run would pile up under fuzz, each stealing
|
||||
// keystrokes for a run already gone.
|
||||
func relayStdin() {
|
||||
buf := make([]byte, 64)
|
||||
for {
|
||||
n, err := os.Stdin.Read(buf)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
consoleMu.Lock()
|
||||
if console != nil {
|
||||
console.Write(buf[:n])
|
||||
}
|
||||
consoleMu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
func fuzz(n int, runFor time.Duration, args []string) error {
|
||||
failed := 0
|
||||
for i := 1; i <= n; i++ {
|
||||
@@ -162,13 +183,10 @@ func run(runFor time.Duration, at string, out io.Writer, args []string) error {
|
||||
// killed when go run dies, and an orphan holding the wire poisons every
|
||||
// measurement after it.
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
// The child's own process group makes the tty off limits to it (reading
|
||||
// from the background raises SIGTTIN), so the harness reads and forwards.
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
go io.Copy(stdin, os.Stdin)
|
||||
consoleMu.Lock()
|
||||
console = stdin
|
||||
consoleMu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user