Optimized and improved the code

Optimized and improved the code for killing core processes in non-Windows environments. Now uses a shell script for precise processing.
This commit is contained in:
2dust
2025-07-30 19:52:45 +08:00
parent 6715d7dce6
commit 3d23f3e3a2
9 changed files with 170 additions and 46 deletions
+24
View File
@@ -223,4 +223,28 @@ public static class FileManager
// ignored
}
}
/// <summary>
/// Creates a Linux shell file with the specified contents.
/// </summary>
/// <param name="fileName"></param>
/// <param name="contents"></param>
/// <param name="overwrite"></param>
/// <returns></returns>
public static async Task<string> CreateLinuxShellFile(string fileName, string contents, bool overwrite)
{
var shFilePath = Utils.GetBinConfigPath(fileName);
// Check if the file already exists and if we should overwrite it
if (!overwrite && File.Exists(shFilePath))
{
return shFilePath;
}
File.Delete(shFilePath);
await File.WriteAllTextAsync(shFilePath, contents);
await Utils.SetLinuxChmod(shFilePath);
return shFilePath;
}
}