Tweak fim kill approach so ALL sub-processes are also killed (this is really important since it's a bash script presently)
Some checks failed
continuous-integration/drone/tag Build is failing
Some checks failed
continuous-integration/drone/tag Build is failing
This commit is contained in:
parent
8b3827220e
commit
30976f60fa
|
@ -5,6 +5,7 @@ import (
|
|||
"io"
|
||||
"log"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/eiannone/keyboard"
|
||||
|
@ -21,6 +22,8 @@ func Slideshow() {
|
|||
|
||||
// Run slideshow
|
||||
fim = exec.Command(CMD_FIM)
|
||||
// Put fim into a process group so ALL processes that may be executed are exited when main process exits
|
||||
fim.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
|
||||
// Setup stdin for fim to control slideshow
|
||||
stdin, err := fim.StdinPipe()
|
||||
|
@ -79,9 +82,13 @@ func Slideshow() {
|
|||
// Exit fim and move to the config UI
|
||||
if event.Key == keyboard.KeyEsc || event.Key == keyboard.KeyEnter || event.Key == keyboard.KeySpace {
|
||||
if fim != nil { // Just in case someone lays on exit key or similar during startup
|
||||
if err := fim.Process.Kill(); err != nil {
|
||||
log.Fatalf("failed to kill fim : %s", err)
|
||||
pgid, err := syscall.Getpgid(fim.Process.Pid)
|
||||
if err == nil {
|
||||
if err := syscall.Kill(-pgid, 9); err != nil {
|
||||
log.Fatalf("failed to kill fim : %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue