diff --git a/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs b/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs
index f9894e9ac9..12a0164a1f 100644
--- a/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs
+++ b/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs
@@ -1,6 +1,8 @@
using System;
+using System.Collections.Generic;
using System.Globalization;
using System.IO;
+using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -62,6 +64,39 @@ namespace Tgstation.Server.Host.System
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
+ ///
+ /// Gets potential paths to the gcore executable.
+ ///
+ /// The potential paths to the gcore executable.
+ static IEnumerable GetPotentialGCorePaths()
+ {
+ var enviromentPath = Environment.GetEnvironmentVariable("PATH");
+ IEnumerable enumerator;
+ if (enviromentPath == null)
+ enumerator = Enumerable.Empty();
+ else
+ {
+ var paths = enviromentPath.Split(';');
+ enumerator = paths
+ .Select(x => x.Split(':'))
+ .SelectMany(x => x);
+ }
+
+ var exeName = "gcore";
+
+ enumerator = enumerator
+ .Concat(new List(2)
+ {
+ "/usr/bin",
+ "/usr/share/bin",
+ "/bin",
+ });
+
+ enumerator = enumerator.Select(x => Path.Combine(x, exeName));
+
+ return enumerator;
+ }
+
///
public void ResumeProcess(global::System.Diagnostics.Process process)
{
@@ -88,8 +123,15 @@ namespace Tgstation.Server.Host.System
ArgumentNullException.ThrowIfNull(process);
ArgumentNullException.ThrowIfNull(outputFile);
- const string GCorePath = "/usr/bin/gcore";
- if (!await ioManager.FileExists(GCorePath, cancellationToken))
+ string? gcorePath = null;
+ foreach (var path in GetPotentialGCorePaths())
+ if (await ioManager.FileExists(path, cancellationToken))
+ {
+ gcorePath = path;
+ break;
+ }
+
+ if (gcorePath == null)
throw new JobException(ErrorCode.MissingGCore);
int pid;
@@ -108,7 +150,7 @@ namespace Tgstation.Server.Host.System
string? output;
int exitCode;
await using (var gcoreProc = await lazyLoadedProcessExecutor.Value.LaunchProcess(
- GCorePath,
+ gcorePath,
Environment.CurrentDirectory,
$"{(!minidump ? "-a " : String.Empty)}-o {outputFile} {process.Id}",
cancellationToken,