context cancellation in exec.CommandContext and os.Exit

81 views
Skip to first unread message

Manlio Perillo

unread,
Jan 19, 2020, 12:38:34 PM1/19/20
to golang-nuts
Hi.

Suppose I have a program that spawns a process with exec.CommandContex and, in a signal handler, cancel the context and calls os.Exit(1).
Is it possible, in theory, that the program exits before the process is actually terminated?


Thanks
Manlio Perillo


Tamás Gulácsi

unread,
Jan 19, 2020, 5:45:34 PM1/19/20
to golang-nuts
Yes.

Never call os.Exit when you still has work to be done.
Even defers are skipped.

Manlio Perillo

unread,
Jan 20, 2020, 2:56:22 AM1/20/20
to golang-nuts
I know.  os.Exit is called in a signal handler.

Thanks
Manlio Perillo
 
Reply all
Reply to author
Forward
0 new messages