Skip to content

Commit

Permalink
cmd/vinegar: wait for roblox to die in procfs
Browse files Browse the repository at this point in the history
  • Loading branch information
apprehensions committed Oct 24, 2023
1 parent 8f3c715 commit 84c3236
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/vinegar/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"fmt"
"io"
"log"
"strconv"
"os"
"time"
"os/exec"
"os/signal"
"path/filepath"
Expand Down Expand Up @@ -116,6 +118,19 @@ func (b *Binary) Run(args ...string) error {
b.Splash.Message("Launching " + b.Alias)

defer func() {
for {
time.Sleep(100 * time.Millisecond)

// This is because there may be a race condition between the process
// procfs depletion and the proccess getting killed.
// CommFound walks over procfs, so here ensure that the process no longer
// exists in procfs.
_, err := os.Stat(filepath.Join("/proc", strconv.Itoa(cmd.Process.Pid)))
if err != nil {
break
}
}

if util.CommFound("Roblox") {
log.Println("Another Roblox instance is already running, not killing wineprefix")
return
Expand Down

0 comments on commit 84c3236

Please sign in to comment.