github.com/cnboonhan/delve@v0.0.0-20230908061759-363f2388c2fb/_fixtures/sigchldprog.go (about)

     1  package main
     2  
     3  import (
     4  	"bufio"
     5  	"fmt"
     6  	"log"
     7  	"os/exec"
     8  )
     9  
    10  func main() {
    11  	cmd := exec.Command("date")
    12  	reader, err := cmd.StdoutPipe()
    13  	if err != nil {
    14  		log.Fatalln(err)
    15  	}
    16  	defer reader.Close()
    17  
    18  	scanner := bufio.NewScanner(reader)
    19  	go func() {
    20  		for scanner.Scan() {
    21  			fmt.Println(scanner.Text())
    22  		}
    23  	}()
    24  	cmd.Start()
    25  	cmd.Wait()
    26  }