session, err := gexec.Start(cmd, io.MultiWriter(GinkgoWriter, &buffer), io.MultiWriter(GinkgoWriter, &buffer)) Expect(err).NotTo(HaveOccurred()) // ... some code that uses the session ... err = session.Kill() Expect(err).NotTo(HaveOccurred())
session, err := gexec.Start(cmd, io.MultiWriter(GinkgoWriter, &buffer), io.MultiWriter(GinkgoWriter, &buffer)) Expect(err).NotTo(HaveOccurred()) // Wait for the subprocess to exit session.Wait() // Kill the subprocess, just in case it didn't exit session.Kill()In this example, we use `session.Wait()` to wait for the subprocess to exit. We then use `session.Kill()` to make sure it has been killed, just in case it didn't exit properly. Overall, `Session.Kill()` is a useful method provided by the `github.com/onsi/gomega/gexec` package for handling subprocesses in tests.