terraform-exec
terraform-exec copied to clipboard
Allow using a new process group for the terraform cli child process
Support using syscall.SysProcAttr with Setpgid: true on the Cmd struct, which creates a new process group for the child process.
This effectively separates the child process from the parent process's signal group, so it won't receive the interrupt signal when you interrupt the parent process.
Motivation - graceful shutdown implementation. When receiving CTRL+C the child process running terraform is interrupted, which is undesirable for my use case.
See: https://stackoverflow.com/questions/33165530/prevent-ctrlc-from-interrupting-exec-command-in-golang/33171307#33171307