[go-nuts] Ensuring resource cleanup when app is killed

2018-01-24 Thread Sundar Nadathur
My golang application creates UNIX sockets in specific paths: /mypath/name1.sock, /mypath/name2.sock etc. It then launches a go routine that listens to one or more of those sockets. I need to ensure that they get cleaned up (removed) at the end. I tried the obvious thing -- use defer in main()

[go-nuts] Re: Ensuring resource cleanup when app is killed

2018-01-24 Thread Sundar Nadathur
Thank you both for the replies. Hi Tamas, I am wondering about: go func() { <-sigCh cancel() } If the program exits normally, presumably sigCh channel will not get notified, and this goroutine will continue to run. How do we ensure that it quits on normal program exit? Regards, Su

[go-nuts] Re: Ensuring resource cleanup when app is killed

2018-01-24 Thread Sundar Nadathur
I am probably mis-understanding or missing something. The golang spec says: Program execution begins by initializing the main package and then invoking the function main. When that function invocation returns, the program exits. *It does not wa

Re: [go-nuts] Re: Ensuring resource cleanup when app is killed

2018-01-24 Thread Sundar Nadathur
e as the program exits. > > I hope that helps to clarify the documentation for you. > > On Wed, Jan 24, 2018 at 11:03 PM Sundar Nadathur > wrote: > >> I am probably mis-understanding or missing something. The golang spec >> <https://golang.org/ref/spec#Program_executi