vendor: Mega update all dependencies
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4080
This commit is contained in:
95
vendor/github.com/onsi/gomega/gexec/session.go
generated
vendored
95
vendor/github.com/onsi/gomega/gexec/session.go
generated
vendored
@@ -60,7 +60,7 @@ Instead, to assert that the command has exited you can use the gexec.Exit matche
|
||||
Ω(session).Should(gexec.Exit())
|
||||
|
||||
When the session exits it closes the stdout and stderr gbytes buffers. This will short circuit any
|
||||
Eventuallys waiting fo the buffers to Say something.
|
||||
Eventuallys waiting for the buffers to Say something.
|
||||
*/
|
||||
func Start(command *exec.Cmd, outWriter io.Writer, errWriter io.Writer) (*Session, error) {
|
||||
exited := make(chan struct{})
|
||||
@@ -92,6 +92,9 @@ func Start(command *exec.Cmd, outWriter io.Writer, errWriter io.Writer) (*Sessio
|
||||
err := command.Start()
|
||||
if err == nil {
|
||||
go session.monitorForExit(exited)
|
||||
trackedSessionsMutex.Lock()
|
||||
defer trackedSessionsMutex.Unlock()
|
||||
trackedSessions = append(trackedSessions, session)
|
||||
}
|
||||
|
||||
return session, err
|
||||
@@ -179,7 +182,7 @@ func (s *Session) Terminate() *Session {
|
||||
}
|
||||
|
||||
/*
|
||||
Terminate sends the running command the passed in signal. It does not wait for the process to exit.
|
||||
Signal sends the running command the passed in signal. It does not wait for the process to exit.
|
||||
|
||||
If the command has already exited, Signal returns silently.
|
||||
|
||||
@@ -212,3 +215,91 @@ func (s *Session) monitorForExit(exited chan<- struct{}) {
|
||||
|
||||
close(exited)
|
||||
}
|
||||
|
||||
var trackedSessions = []*Session{}
|
||||
var trackedSessionsMutex = &sync.Mutex{}
|
||||
|
||||
/*
|
||||
Kill sends a SIGKILL signal to all the processes started by Run, and waits for them to exit.
|
||||
The timeout specified is applied to each process killed.
|
||||
|
||||
If any of the processes already exited, KillAndWait returns silently.
|
||||
*/
|
||||
func KillAndWait(timeout ...interface{}) {
|
||||
trackedSessionsMutex.Lock()
|
||||
defer trackedSessionsMutex.Unlock()
|
||||
for _, session := range trackedSessions {
|
||||
session.Kill().Wait(timeout...)
|
||||
}
|
||||
trackedSessions = []*Session{}
|
||||
}
|
||||
|
||||
/*
|
||||
Kill sends a SIGTERM signal to all the processes started by Run, and waits for them to exit.
|
||||
The timeout specified is applied to each process killed.
|
||||
|
||||
If any of the processes already exited, TerminateAndWait returns silently.
|
||||
*/
|
||||
func TerminateAndWait(timeout ...interface{}) {
|
||||
trackedSessionsMutex.Lock()
|
||||
defer trackedSessionsMutex.Unlock()
|
||||
for _, session := range trackedSessions {
|
||||
session.Terminate().Wait(timeout...)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Kill sends a SIGKILL signal to all the processes started by Run.
|
||||
It does not wait for the processes to exit.
|
||||
|
||||
If any of the processes already exited, Kill returns silently.
|
||||
*/
|
||||
func Kill() {
|
||||
trackedSessionsMutex.Lock()
|
||||
defer trackedSessionsMutex.Unlock()
|
||||
for _, session := range trackedSessions {
|
||||
session.Kill()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Terminate sends a SIGTERM signal to all the processes started by Run.
|
||||
It does not wait for the processes to exit.
|
||||
|
||||
If any of the processes already exited, Terminate returns silently.
|
||||
*/
|
||||
func Terminate() {
|
||||
trackedSessionsMutex.Lock()
|
||||
defer trackedSessionsMutex.Unlock()
|
||||
for _, session := range trackedSessions {
|
||||
session.Terminate()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Signal sends the passed in signal to all the processes started by Run.
|
||||
It does not wait for the processes to exit.
|
||||
|
||||
If any of the processes already exited, Signal returns silently.
|
||||
*/
|
||||
func Signal(signal os.Signal) {
|
||||
trackedSessionsMutex.Lock()
|
||||
defer trackedSessionsMutex.Unlock()
|
||||
for _, session := range trackedSessions {
|
||||
session.Signal(signal)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Interrupt sends the SIGINT signal to all the processes started by Run.
|
||||
It does not wait for the processes to exit.
|
||||
|
||||
If any of the processes already exited, Interrupt returns silently.
|
||||
*/
|
||||
func Interrupt() {
|
||||
trackedSessionsMutex.Lock()
|
||||
defer trackedSessionsMutex.Unlock()
|
||||
for _, session := range trackedSessions {
|
||||
session.Interrupt()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user