blob: e1cfb3b269b79434d44fc2c803755a6e0ef5d9a0 [file] [log] [blame]
Brad Fitzpatrick51947442016-03-01 22:57:46 +00001// Copyright 2013 The Go Authors. All rights reserved.
Jeff R. Allen6563d862013-01-30 10:02:01 -08002// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
Tamir Duberstein4a617642021-06-11 18:14:03 -04005//go:build !fuchsia && !js && !plan9 && !windows
Jeff R. Allen6563d862013-01-30 10:02:01 -08006
7package net
8
9import (
10 "bytes"
Brad Fitzpatrick2cefd122016-04-06 19:02:27 +000011 "internal/testenv"
Jeff R. Allen6563d862013-01-30 10:02:01 -080012 "os"
Albert Strasheim309d88e2013-02-06 06:45:57 -080013 "reflect"
14 "runtime"
Jeff R. Allen6563d862013-01-30 10:02:01 -080015 "syscall"
16 "testing"
17 "time"
18)
19
Jeff R. Allen6563d862013-01-30 10:02:01 -080020func TestReadUnixgramWithUnnamedSocket(t *testing.T) {
Mikio Hara7b2b45e2015-03-26 23:26:45 +090021 if !testableNetwork("unixgram") {
22 t.Skip("unixgram test")
David Crawshawac080fa2015-03-09 09:06:11 -040023 }
Brad Fitzpatrick2cefd122016-04-06 19:02:27 +000024 if runtime.GOOS == "openbsd" {
25 testenv.SkipFlaky(t, 15157)
26 }
Mikio Hara7b2b45e2015-03-26 23:26:45 +090027
Bryan C. Mills4b3d8d12021-12-09 11:55:20 -050028 addr := testUnixAddr(t)
Jeff R. Allen6563d862013-01-30 10:02:01 -080029 la, err := ResolveUnixAddr("unixgram", addr)
30 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +090031 t.Fatal(err)
Jeff R. Allen6563d862013-01-30 10:02:01 -080032 }
33 c, err := ListenUnixgram("unixgram", la)
34 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +090035 t.Fatal(err)
Jeff R. Allen6563d862013-01-30 10:02:01 -080036 }
37 defer func() {
38 c.Close()
39 os.Remove(addr)
40 }()
41
42 off := make(chan bool)
43 data := [5]byte{1, 2, 3, 4, 5}
Jeff R. Allen6563d862013-01-30 10:02:01 -080044 go func() {
45 defer func() { off <- true }()
46 s, err := syscall.Socket(syscall.AF_UNIX, syscall.SOCK_DGRAM, 0)
47 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +090048 t.Error(err)
Jeff R. Allen6563d862013-01-30 10:02:01 -080049 return
50 }
51 defer syscall.Close(s)
52 rsa := &syscall.SockaddrUnix{Name: addr}
53 if err := syscall.Sendto(s, data[:], 0, rsa); err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +090054 t.Error(err)
Jeff R. Allen6563d862013-01-30 10:02:01 -080055 return
56 }
57 }()
58
59 <-off
60 b := make([]byte, 64)
61 c.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
62 n, from, err := c.ReadFrom(b)
63 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +090064 t.Fatal(err)
Jeff R. Allen6563d862013-01-30 10:02:01 -080065 }
66 if from != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +090067 t.Fatalf("unexpected peer address: %v", from)
Jeff R. Allen6563d862013-01-30 10:02:01 -080068 }
69 if !bytes.Equal(b[:n], data[:]) {
Mikio Haraf77e10f2015-05-01 12:38:42 +090070 t.Fatalf("got %v; want %v", b[:n], data[:])
Jeff R. Allen6563d862013-01-30 10:02:01 -080071 }
72}
73
Mikio Hara03eb1322015-04-20 23:15:00 +090074func TestUnixgramZeroBytePayload(t *testing.T) {
75 if !testableNetwork("unixgram") {
76 t.Skip("unixgram test")
77 }
78
Bryan C. Millsb55cbbb2021-12-09 11:42:42 -050079 c1 := newLocalPacketListener(t, "unixgram")
Mikio Hara03eb1322015-04-20 23:15:00 +090080 defer os.Remove(c1.LocalAddr().String())
81 defer c1.Close()
82
83 c2, err := Dial("unixgram", c1.LocalAddr().String())
84 if err != nil {
85 t.Fatal(err)
86 }
87 defer os.Remove(c2.LocalAddr().String())
88 defer c2.Close()
89
90 for _, genericRead := range []bool{false, true} {
91 n, err := c2.Write(nil)
92 if err != nil {
93 t.Fatal(err)
94 }
95 if n != 0 {
96 t.Errorf("got %d; want 0", n)
97 }
98 c1.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
99 var b [1]byte
100 var peer Addr
101 if genericRead {
102 _, err = c1.(Conn).Read(b[:])
103 } else {
104 _, peer, err = c1.ReadFrom(b[:])
105 }
106 switch err {
107 case nil: // ReadFrom succeeds
108 if peer != nil { // peer is connected-mode
109 t.Fatalf("unexpected peer address: %v", peer)
110 }
111 default: // Read may timeout, it depends on the platform
Ian Lance Taylord422f542020-04-17 15:42:12 -0700112 if !isDeadlineExceeded(err) {
Mikio Hara03eb1322015-04-20 23:15:00 +0900113 t.Fatal(err)
114 }
115 }
116 }
117}
118
119func TestUnixgramZeroByteBuffer(t *testing.T) {
Mikio Hara7b2b45e2015-03-26 23:26:45 +0900120 if !testableNetwork("unixgram") {
121 t.Skip("unixgram test")
David Crawshawac080fa2015-03-09 09:06:11 -0400122 }
Jeff R. Allen6563d862013-01-30 10:02:01 -0800123 // issue 4352: Recvfrom failed with "address family not
124 // supported by protocol family" if zero-length buffer provided
125
Bryan C. Millsb55cbbb2021-12-09 11:42:42 -0500126 c1 := newLocalPacketListener(t, "unixgram")
Mikio Hara03eb1322015-04-20 23:15:00 +0900127 defer os.Remove(c1.LocalAddr().String())
128 defer c1.Close()
Jeff R. Allen6563d862013-01-30 10:02:01 -0800129
Mikio Hara03eb1322015-04-20 23:15:00 +0900130 c2, err := Dial("unixgram", c1.LocalAddr().String())
131 if err != nil {
132 t.Fatal(err)
133 }
134 defer os.Remove(c2.LocalAddr().String())
135 defer c2.Close()
136
Mikio Haraf77e10f2015-05-01 12:38:42 +0900137 b := []byte("UNIXGRAM ZERO BYTE BUFFER TEST")
Mikio Hara03eb1322015-04-20 23:15:00 +0900138 for _, genericRead := range []bool{false, true} {
139 n, err := c2.Write(b)
Jeff R. Allen6563d862013-01-30 10:02:01 -0800140 if err != nil {
Mikio Hara03eb1322015-04-20 23:15:00 +0900141 t.Fatal(err)
Jeff R. Allen6563d862013-01-30 10:02:01 -0800142 }
Mikio Hara03eb1322015-04-20 23:15:00 +0900143 if n != len(b) {
144 t.Errorf("got %d; want %d", n, len(b))
Jeff R. Allen6563d862013-01-30 10:02:01 -0800145 }
Mikio Hara03eb1322015-04-20 23:15:00 +0900146 c1.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
147 var peer Addr
148 if genericRead {
149 _, err = c1.(Conn).Read(nil)
150 } else {
151 _, peer, err = c1.ReadFrom(nil)
152 }
153 switch err {
154 case nil: // ReadFrom succeeds
155 if peer != nil { // peer is connected-mode
156 t.Fatalf("unexpected peer address: %v", peer)
157 }
158 default: // Read may timeout, it depends on the platform
Ian Lance Taylord422f542020-04-17 15:42:12 -0700159 if !isDeadlineExceeded(err) {
Mikio Hara03eb1322015-04-20 23:15:00 +0900160 t.Fatal(err)
161 }
162 }
Jeff R. Allen6563d862013-01-30 10:02:01 -0800163 }
164}
Albert Strasheim309d88e2013-02-06 06:45:57 -0800165
Mikio Hara67a51812014-04-02 19:42:05 +0900166func TestUnixgramWrite(t *testing.T) {
Mikio Hara7b2b45e2015-03-26 23:26:45 +0900167 if !testableNetwork("unixgram") {
168 t.Skip("unixgram test")
David Crawshawac080fa2015-03-09 09:06:11 -0400169 }
Mikio Hara7b2b45e2015-03-26 23:26:45 +0900170
Bryan C. Mills4b3d8d12021-12-09 11:55:20 -0500171 addr := testUnixAddr(t)
Mikio Hara67a51812014-04-02 19:42:05 +0900172 laddr, err := ResolveUnixAddr("unixgram", addr)
173 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900174 t.Fatal(err)
Mikio Hara67a51812014-04-02 19:42:05 +0900175 }
176 c, err := ListenPacket("unixgram", addr)
177 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900178 t.Fatal(err)
Mikio Hara67a51812014-04-02 19:42:05 +0900179 }
180 defer os.Remove(addr)
181 defer c.Close()
182
183 testUnixgramWriteConn(t, laddr)
184 testUnixgramWritePacketConn(t, laddr)
185}
186
187func testUnixgramWriteConn(t *testing.T, raddr *UnixAddr) {
188 c, err := Dial("unixgram", raddr.String())
189 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900190 t.Fatal(err)
Mikio Hara67a51812014-04-02 19:42:05 +0900191 }
192 defer c.Close()
193
Mikio Haraf77e10f2015-05-01 12:38:42 +0900194 b := []byte("CONNECTED-MODE SOCKET")
195 if _, err := c.(*UnixConn).WriteToUnix(b, raddr); err == nil {
196 t.Fatal("should fail")
Mikio Hara67a51812014-04-02 19:42:05 +0900197 } else if err.(*OpError).Err != ErrWriteToConnected {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900198 t.Fatalf("should fail as ErrWriteToConnected: %v", err)
Mikio Hara67a51812014-04-02 19:42:05 +0900199 }
Mikio Haraf77e10f2015-05-01 12:38:42 +0900200 if _, err = c.(*UnixConn).WriteTo(b, raddr); err == nil {
201 t.Fatal("should fail")
Mikio Hara67a51812014-04-02 19:42:05 +0900202 } else if err.(*OpError).Err != ErrWriteToConnected {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900203 t.Fatalf("should fail as ErrWriteToConnected: %v", err)
Mikio Hara67a51812014-04-02 19:42:05 +0900204 }
Mikio Haraf77e10f2015-05-01 12:38:42 +0900205 if _, _, err = c.(*UnixConn).WriteMsgUnix(b, nil, raddr); err == nil {
206 t.Fatal("should fail")
Mikio Hara67a51812014-04-02 19:42:05 +0900207 } else if err.(*OpError).Err != ErrWriteToConnected {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900208 t.Fatalf("should fail as ErrWriteToConnected: %v", err)
Mikio Hara67a51812014-04-02 19:42:05 +0900209 }
Mikio Haraf77e10f2015-05-01 12:38:42 +0900210 if _, err := c.Write(b); err != nil {
211 t.Fatal(err)
Mikio Hara67a51812014-04-02 19:42:05 +0900212 }
213}
214
215func testUnixgramWritePacketConn(t *testing.T, raddr *UnixAddr) {
Bryan C. Mills4b3d8d12021-12-09 11:55:20 -0500216 addr := testUnixAddr(t)
Mikio Hara67a51812014-04-02 19:42:05 +0900217 c, err := ListenPacket("unixgram", addr)
218 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900219 t.Fatal(err)
Mikio Hara67a51812014-04-02 19:42:05 +0900220 }
221 defer os.Remove(addr)
222 defer c.Close()
223
Mikio Haraf77e10f2015-05-01 12:38:42 +0900224 b := []byte("UNCONNECTED-MODE SOCKET")
225 if _, err := c.(*UnixConn).WriteToUnix(b, raddr); err != nil {
226 t.Fatal(err)
Mikio Hara67a51812014-04-02 19:42:05 +0900227 }
Mikio Haraf77e10f2015-05-01 12:38:42 +0900228 if _, err := c.WriteTo(b, raddr); err != nil {
229 t.Fatal(err)
Mikio Hara67a51812014-04-02 19:42:05 +0900230 }
Mikio Haraf77e10f2015-05-01 12:38:42 +0900231 if _, _, err := c.(*UnixConn).WriteMsgUnix(b, nil, raddr); err != nil {
232 t.Fatal(err)
Mikio Hara67a51812014-04-02 19:42:05 +0900233 }
Mikio Haraf77e10f2015-05-01 12:38:42 +0900234 if _, err := c.(*UnixConn).Write(b); err == nil {
235 t.Fatal("should fail")
Mikio Hara67a51812014-04-02 19:42:05 +0900236 }
237}
238
Mikio Harabfb32dc2013-03-23 22:32:19 +0900239func TestUnixConnLocalAndRemoteNames(t *testing.T) {
Mikio Hara7b2b45e2015-03-26 23:26:45 +0900240 if !testableNetwork("unix") {
241 t.Skip("unix test")
David Crawshawac080fa2015-03-09 09:06:11 -0400242 }
Mikio Hara7b2b45e2015-03-26 23:26:45 +0900243
Mikio Haraf0775052015-04-02 23:11:39 +0900244 handler := func(ls *localServer, ln Listener) {}
Bryan C. Mills4b3d8d12021-12-09 11:55:20 -0500245 for _, laddr := range []string{"", testUnixAddr(t)} {
ChaiShushan6ab49fb2013-08-05 11:59:59 +1000246 laddr := laddr
Bryan C. Mills4b3d8d12021-12-09 11:55:20 -0500247 taddr := testUnixAddr(t)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900248 ta, err := ResolveUnixAddr("unix", taddr)
249 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900250 t.Fatal(err)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900251 }
252 ln, err := ListenUnix("unix", ta)
253 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900254 t.Fatal(err)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900255 }
Bryan C. Millsb55cbbb2021-12-09 11:42:42 -0500256 ls := (&streamListener{Listener: ln}).newLocalServer()
Mikio Haraf0775052015-04-02 23:11:39 +0900257 defer ls.teardown()
258 if err := ls.buildup(handler); err != nil {
259 t.Fatal(err)
260 }
Mikio Harabfb32dc2013-03-23 22:32:19 +0900261
262 la, err := ResolveUnixAddr("unix", laddr)
263 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900264 t.Fatal(err)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900265 }
266 c, err := DialUnix("unix", la, ta)
267 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900268 t.Fatal(err)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900269 }
270 defer func() {
271 c.Close()
272 if la != nil {
273 defer os.Remove(laddr)
274 }
275 }()
276 if _, err := c.Write([]byte("UNIXCONN LOCAL AND REMOTE NAME TEST")); err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900277 t.Fatal(err)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900278 }
279
David Crawshaw8b6dafa2014-07-08 13:41:18 -0400280 switch runtime.GOOS {
281 case "android", "linux":
282 if laddr == "" {
283 laddr = "@" // autobind feature
284 }
Mikio Harabfb32dc2013-03-23 22:32:19 +0900285 }
286 var connAddrs = [3]struct{ got, want Addr }{
287 {ln.Addr(), ta},
288 {c.LocalAddr(), &UnixAddr{Name: laddr, Net: "unix"}},
289 {c.RemoteAddr(), ta},
290 }
291 for _, ca := range connAddrs {
292 if !reflect.DeepEqual(ca.got, ca.want) {
293 t.Fatalf("got %#v, expected %#v", ca.got, ca.want)
294 }
295 }
Mikio Harabfb32dc2013-03-23 22:32:19 +0900296 }
297}
298
299func TestUnixgramConnLocalAndRemoteNames(t *testing.T) {
Mikio Hara7b2b45e2015-03-26 23:26:45 +0900300 if !testableNetwork("unixgram") {
301 t.Skip("unixgram test")
David Crawshawac080fa2015-03-09 09:06:11 -0400302 }
Mikio Hara7b2b45e2015-03-26 23:26:45 +0900303
Bryan C. Mills4b3d8d12021-12-09 11:55:20 -0500304 for _, laddr := range []string{"", testUnixAddr(t)} {
ChaiShushan6ab49fb2013-08-05 11:59:59 +1000305 laddr := laddr
Bryan C. Mills4b3d8d12021-12-09 11:55:20 -0500306 taddr := testUnixAddr(t)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900307 ta, err := ResolveUnixAddr("unixgram", taddr)
308 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900309 t.Fatal(err)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900310 }
311 c1, err := ListenUnixgram("unixgram", ta)
312 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900313 t.Fatal(err)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900314 }
315 defer func() {
316 c1.Close()
317 os.Remove(taddr)
318 }()
319
320 var la *UnixAddr
321 if laddr != "" {
Mikio Harabfb32dc2013-03-23 22:32:19 +0900322 if la, err = ResolveUnixAddr("unixgram", laddr); err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900323 t.Fatal(err)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900324 }
325 }
326 c2, err := DialUnix("unixgram", la, ta)
327 if err != nil {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900328 t.Fatal(err)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900329 }
330 defer func() {
331 c2.Close()
332 if la != nil {
333 defer os.Remove(laddr)
334 }
335 }()
336
David Crawshaw8b6dafa2014-07-08 13:41:18 -0400337 switch runtime.GOOS {
338 case "android", "linux":
339 if laddr == "" {
340 laddr = "@" // autobind feature
341 }
Mikio Harabfb32dc2013-03-23 22:32:19 +0900342 }
David Crawshaw8b6dafa2014-07-08 13:41:18 -0400343
Mikio Harabfb32dc2013-03-23 22:32:19 +0900344 var connAddrs = [4]struct{ got, want Addr }{
345 {c1.LocalAddr(), ta},
346 {c1.RemoteAddr(), nil},
347 {c2.LocalAddr(), &UnixAddr{Name: laddr, Net: "unixgram"}},
348 {c2.RemoteAddr(), ta},
349 }
350 for _, ca := range connAddrs {
351 if !reflect.DeepEqual(ca.got, ca.want) {
Mikio Haraf77e10f2015-05-01 12:38:42 +0900352 t.Fatalf("got %#v; want %#v", ca.got, ca.want)
Mikio Harabfb32dc2013-03-23 22:32:19 +0900353 }
354 }
Albert Strasheim309d88e2013-02-06 06:45:57 -0800355 }
356}
Russ Cox18d27b22015-08-18 22:19:58 -0400357
Russ Cox21907502015-12-10 23:51:36 -0500358func TestUnixUnlink(t *testing.T) {
359 if !testableNetwork("unix") {
360 t.Skip("unix test")
361 }
Bryan C. Mills4b3d8d12021-12-09 11:55:20 -0500362 name := testUnixAddr(t)
Russ Coxeb88b3e2016-10-26 20:23:03 -0400363
364 listen := func(t *testing.T) *UnixListener {
365 l, err := Listen("unix", name)
366 if err != nil {
367 t.Fatal(err)
368 }
369 return l.(*UnixListener)
Russ Cox21907502015-12-10 23:51:36 -0500370 }
Russ Coxeb88b3e2016-10-26 20:23:03 -0400371 checkExists := func(t *testing.T, desc string) {
372 if _, err := os.Stat(name); err != nil {
373 t.Fatalf("unix socket does not exist %s: %v", desc, err)
374 }
Russ Cox21907502015-12-10 23:51:36 -0500375 }
Russ Coxeb88b3e2016-10-26 20:23:03 -0400376 checkNotExists := func(t *testing.T, desc string) {
377 if _, err := os.Stat(name); err == nil {
378 t.Fatalf("unix socket does exist %s: %v", desc, err)
379 }
Russ Cox21907502015-12-10 23:51:36 -0500380 }
Russ Coxeb88b3e2016-10-26 20:23:03 -0400381
382 // Listener should remove on close.
383 t.Run("Listen", func(t *testing.T) {
384 l := listen(t)
385 checkExists(t, "after Listen")
386 l.Close()
387 checkNotExists(t, "after Listener close")
388 })
389
390 // FileListener should not.
391 t.Run("FileListener", func(t *testing.T) {
392 l := listen(t)
393 f, _ := l.File()
394 l1, _ := FileListener(f)
395 checkExists(t, "after FileListener")
396 f.Close()
397 checkExists(t, "after File close")
398 l1.Close()
399 checkExists(t, "after FileListener close")
400 l.Close()
401 checkNotExists(t, "after Listener close")
402 })
403
404 // Only first call to l.Close should remove.
405 t.Run("SecondClose", func(t *testing.T) {
406 l := listen(t)
407 checkExists(t, "after Listen")
408 l.Close()
409 checkNotExists(t, "after Listener close")
Russ Cox4f1b0a42020-10-29 14:17:47 -0400410 if err := os.WriteFile(name, []byte("hello world"), 0666); err != nil {
Russ Coxeb88b3e2016-10-26 20:23:03 -0400411 t.Fatalf("cannot recreate socket file: %v", err)
412 }
413 checkExists(t, "after writing temp file")
414 l.Close()
415 checkExists(t, "after second Listener close")
416 os.Remove(name)
417 })
418
419 // SetUnlinkOnClose should do what it says.
420
421 t.Run("Listen/SetUnlinkOnClose(true)", func(t *testing.T) {
422 l := listen(t)
423 checkExists(t, "after Listen")
424 l.SetUnlinkOnClose(true)
425 l.Close()
426 checkNotExists(t, "after Listener close")
427 })
428
429 t.Run("Listen/SetUnlinkOnClose(false)", func(t *testing.T) {
430 l := listen(t)
431 checkExists(t, "after Listen")
432 l.SetUnlinkOnClose(false)
433 l.Close()
434 checkExists(t, "after Listener close")
435 os.Remove(name)
436 })
437
438 t.Run("FileListener/SetUnlinkOnClose(true)", func(t *testing.T) {
439 l := listen(t)
440 f, _ := l.File()
441 l1, _ := FileListener(f)
442 checkExists(t, "after FileListener")
443 l1.(*UnixListener).SetUnlinkOnClose(true)
444 f.Close()
445 checkExists(t, "after File close")
446 l1.Close()
447 checkNotExists(t, "after FileListener close")
448 l.Close()
449 })
450
451 t.Run("FileListener/SetUnlinkOnClose(false)", func(t *testing.T) {
452 l := listen(t)
453 f, _ := l.File()
454 l1, _ := FileListener(f)
455 checkExists(t, "after FileListener")
456 l1.(*UnixListener).SetUnlinkOnClose(false)
457 f.Close()
458 checkExists(t, "after File close")
459 l1.Close()
460 checkExists(t, "after FileListener close")
461 l.Close()
462 })
Russ Cox21907502015-12-10 23:51:36 -0500463}