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

2018-01-24 Thread Sundar Nadathur
Thank you! Got it. Regards, Sundar On Wednesday, January 24, 2018 at 3:23:04 PM UTC-8, Matt Harden wrote: > > When the program exits, all goroutines die instantly. The doc is saying > that the program does not wait for any goroutine to complete except the > "main" goroutine (the one that invoke

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

2018-01-24 Thread Matt Harden
When the program exits, all goroutines die instantly. The doc is saying that the program does not wait for any goroutine to complete except the "main" goroutine (the one that invoked the function main at startup). If you do want to wait for other goroutines to exit before exiting the program, which

[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

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

2018-01-24 Thread Tamás Gulácsi
if the main goroutine exits, all other goroutines exit, too. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more op

[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