loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a check for when the command is canceled by the program on Window… (#29538)

Close #29509

Windows, unlike Linux, does not have signal-specified exit codes.
Therefore, we should add a Windows-specific check for Windows. If we
don't do this, the logs will always show a failed status, even though
the command actually works correctly.

If you check the Go source code in exec_windows.go, you will see that it
always returns exit code 1.

![image](https://github.com/go-gitea/gitea/assets/30816317/9dfd7c70-9995-47d9-9641-db793f58770c)

The exit code 1 does not exclusively signify a SIGNAL KILL; it can
indicate any issue that occurs when a program fails.

(cherry picked from commit 423372d84ab3d885e47d4a00cd69d6040b61cc4c)

authored by

charles and committed by
Earl Warren
d509031e db19d4eb

+12
+12
modules/git/command.go
··· 12 12 "io" 13 13 "os" 14 14 "os/exec" 15 + "runtime" 15 16 "strings" 16 17 "time" 17 18 ··· 342 343 elapsed := time.Since(startTime) 343 344 if elapsed > time.Second { 344 345 log.Debug("slow git.Command.Run: %s (%s)", c, elapsed) 346 + } 347 + 348 + // We need to check if the context is canceled by the program on Windows. 349 + // This is because Windows does not have signal checking when terminating the process. 350 + // It always returns exit code 1, unlike Linux, which has many exit codes for signals. 351 + if runtime.GOOS == "windows" && 352 + err != nil && 353 + err.Error() == "" && 354 + cmd.ProcessState.ExitCode() == 1 && 355 + ctx.Err() == context.Canceled { 356 + return ctx.Err() 345 357 } 346 358 347 359 if err != nil && ctx.Err() != context.DeadlineExceeded {