Fix subprocesses getting killed when the main process is force killed (fixes rcwd w/TOTP and clipboard clearing issues)

This commit is contained in:
2025-11-09 23:50:15 -05:00
parent bf1399ce8d
commit 8f4590cf34
3 changed files with 6 additions and 0 deletions
+2
View File
@@ -5,6 +5,7 @@ package clip
import (
"os"
"os/exec"
"syscall"
"github.com/rwinkhart/go-boilerplate/back"
)
@@ -13,6 +14,7 @@ import (
// For non-interactive CLI implementations, an entirely separate process is created for this purpose.
func LaunchClipClearProcess(copySubject string) {
cmd := exec.Command(os.Args[0], "clipclear")
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
_ = back.WriteToStdin(cmd, copySubject)
_ = cmd.Start()
os.Exit(0) // use os.Exit directly since this version of this function is only meant for non-interactive CLI implementations
+2
View File
@@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"strconv"
"syscall"
"github.com/rwinkhart/go-boilerplate/back"
)
@@ -14,6 +15,7 @@ import (
// For non-interactive CLI implementations, an entirely separate process is created for this purpose.
func LaunchClipClearProcess(copySubject string, isWayland bool) {
cmd := exec.Command(os.Args[0], "clipclear", strconv.FormatBool(isWayland))
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
_ = back.WriteToStdin(cmd, copySubject)
_ = cmd.Start()
os.Exit(0) // use os.Exit directly since this version of this function is only meant for non-interactive CLI implementations
+2
View File
@@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"strings"
"syscall"
"github.com/rwinkhart/go-boilerplate/back"
"github.com/rwinkhart/libmutton/global"
@@ -84,6 +85,7 @@ func launchRCWDProcess() []byte {
if Daemonize {
cmd := exec.Command(os.Args[0], "startrcwd")
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
_ = back.WriteToStdin(cmd, string(password))
_ = cmd.Start()
}