-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
- Loading branch information
Showing
15 changed files
with
594 additions
and
594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
package winquit | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"os" | ||
"syscall" | ||
) | ||
|
||
type baseChannelType interface { | ||
getKey() any | ||
notifyNonBlocking() | ||
notifyBlocking() | ||
getKey() any | ||
notifyNonBlocking() | ||
notifyBlocking() | ||
} | ||
|
||
type boolChannelType struct { | ||
channel chan bool | ||
channel chan bool | ||
} | ||
|
||
func (b *boolChannelType) getKey() any { | ||
return b.channel | ||
return b.channel | ||
} | ||
|
||
func (b *boolChannelType) notifyNonBlocking() { | ||
select { | ||
case b.channel <- true: | ||
default: | ||
} | ||
select { | ||
case b.channel <- true: | ||
default: | ||
} | ||
} | ||
|
||
func (s *boolChannelType) notifyBlocking() { | ||
s.channel <- true | ||
s.channel <- true | ||
} | ||
|
||
type sigChannelType struct { | ||
channel chan os.Signal | ||
channel chan os.Signal | ||
} | ||
|
||
func (s *sigChannelType) getKey() any { | ||
return s.channel | ||
return s.channel | ||
} | ||
|
||
func (s *sigChannelType) notifyNonBlocking() { | ||
select { | ||
case s.channel <- syscall.SIGTERM: | ||
default: | ||
} | ||
select { | ||
case s.channel <- syscall.SIGTERM: | ||
default: | ||
} | ||
} | ||
|
||
func (s *sigChannelType) notifyBlocking() { | ||
s.channel <- syscall.SIGTERM | ||
s.channel <- syscall.SIGTERM | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
package winquit | ||
|
||
import ( | ||
"os" | ||
"time" | ||
"os" | ||
"time" | ||
|
||
"github.com/containers/winquit/pkg/winquit/win32" | ||
"github.com/sirupsen/logrus" | ||
"github.com/containers/winquit/pkg/winquit/win32" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func requestQuit(pid int) error { | ||
threads, err := win32.GetProcThreads(uint32(pid)) | ||
if err != nil { | ||
return err | ||
} | ||
threads, err := win32.GetProcThreads(uint32(pid)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, thread := range threads { | ||
logrus.Debugf("Closing windows on thread %d", thread) | ||
win32.CloseThreadWindows(uint32(thread)) | ||
} | ||
for _, thread := range threads { | ||
logrus.Debugf("Closing windows on thread %d", thread) | ||
win32.CloseThreadWindows(uint32(thread)) | ||
} | ||
|
||
return nil | ||
return nil | ||
} | ||
|
||
func quitProcess(pid int, waitNicely time.Duration) error { | ||
_ = RequestQuit(pid) | ||
_ = RequestQuit(pid) | ||
|
||
proc, err := os.FindProcess(pid) | ||
if err != nil { | ||
return nil | ||
} | ||
proc, err := os.FindProcess(pid) | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
done := make(chan bool) | ||
done := make(chan bool) | ||
|
||
go func() { | ||
proc.Wait() | ||
done <- true | ||
}() | ||
go func() { | ||
proc.Wait() | ||
done <- true | ||
}() | ||
|
||
select { | ||
case <-done: | ||
return nil | ||
case <-time.After(waitNicely): | ||
} | ||
select { | ||
case <-done: | ||
return nil | ||
case <-time.After(waitNicely): | ||
} | ||
|
||
return proc.Kill() | ||
return proc.Kill() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
package winquit | ||
|
||
import ( | ||
"os" | ||
"os" | ||
) | ||
|
||
func notifyOnQuit(done chan bool) { | ||
|
Oops, something went wrong.