MustWrite communicates listening address addr to the parent process via the file descriptor number passed to -addrfd, if any. It must be called precisely once.
(addr string)
| 14 | // file descriptor number passed to -addrfd, if any. It must be called precisely |
| 15 | // once. |
| 16 | func MustWrite(addr string) { |
| 17 | if *addrfd == -1 { |
| 18 | return |
| 19 | } |
| 20 | log.Printf("%s is listening on %s", os.Args[0], addr) |
| 21 | f := os.NewFile(uintptr(*addrfd), "") |
| 22 | if _, err := f.Write([]byte(addr)); err != nil { |
| 23 | log.Fatal(err) |
| 24 | } |
| 25 | if err := f.Close(); err != nil { |
| 26 | log.Fatal(err) |
| 27 | } |
| 28 | } |
no test coverage detected