Skip to content

Commit c4fa997

Browse files
committed
Fix: improved killing of internal processes
1 parent b9f08db commit c4fa997

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

launcher-config/internal/admin_other.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ func preAgentStart() {
2020
func postAgentStart(file string) {
2121
if !executor.IsAdmin() {
2222
for i := 0; i < 30; i++ {
23-
_, proc, _ := process.Process(file)
24-
if proc != nil {
23+
if _, proc, err := process.Process(file); err == nil && proc != nil {
2524
break
2625
}
2726
time.Sleep(time.Second)

launcher-config/internal/cmd/revert.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,9 @@ var revertCmd = &cobra.Command{
236236
}
237237
if failedStopAgent {
238238
exeFileName := common.GetExeFileName(true, common.LauncherConfigAdminAgent)
239-
if _, _, err := commonProcess.Process(exeFileName); err == nil {
239+
if pid, proc, err := commonProcess.Process(exeFileName); err == nil {
240240
if isAdmin {
241-
_, err := commonProcess.Kill(exeFileName)
242-
if err == nil {
241+
if err := commonProcess.KillProc(pid, proc); err == nil {
243242
fmt.Println("Successfully killed 'config-admin-agent'.")
244243
failedStopAgent = false
245244
} else {
@@ -248,6 +247,8 @@ var revertCmd = &cobra.Command{
248247
} else {
249248
fmt.Println("Re-run as administrator to kill 'config-admin-agent'")
250249
}
250+
} else {
251+
failedStopAgent = false
251252
}
252253
}
253254
if failedStopAgent && errorCode == common.ErrSuccess {

launcher/internal/cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,15 @@ var (
210210
}
211211
fmt.Println(`...`)
212212
if revertResult := executor.RunRevert(gameId, true, runtime.GOOS == "windows", true, true, true, true, false); !revertResult.Success() {
213-
if _, _, err = commonProcess.Process(common.GetExeFileName(false, common.LauncherConfigAdminAgent)); err == nil {
213+
if _, proc, err = commonProcess.Process(common.GetExeFileName(false, common.LauncherConfigAdminAgent)); err == nil && proc != nil {
214214
fmt.Println("Failed to kill 'config-admin-agent' process: ", err, "Kill it using the task manager with admin rights.")
215215
} else {
216216
fmt.Println("Failed to cleanup configuration, try to remove certificates and/or host mappings manually.")
217217
}
218218
return
219219
}
220220
pidPath, proc, err = commonProcess.Process(common.GetExeFileName(false, common.Server))
221-
if err == nil && proc != nil && pidPath != "" {
221+
if err == nil && proc != nil {
222222
fmt.Println("'Server' is already running, If you did not start it manually, kill the 'server' process using the task manager and execute the 'launcher' again.")
223223
}
224224
defer func() {

0 commit comments

Comments
 (0)