mirror of
https://github.com/actions/runner.git
synced 2025-12-11 04:46:58 +00:00
Check if file exists before reading
This commit is contained in:
@@ -62,11 +62,16 @@ namespace GitHub.Runner.Worker
|
|||||||
throw new NotSupportedException("Container feature is not supported when runner is already running inside container.");
|
throw new NotSupportedException("Container feature is not supported when runner is already running inside container.");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
var initProcessCgroup = File.ReadLines("/proc/1/cgroup");
|
var path = "/proc/1/cgroup";
|
||||||
|
// OSX does not have this file, but you cannot run OSX as a base image for docker containers currently.
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
var initProcessCgroup = File.ReadLines(path);
|
||||||
if (initProcessCgroup.Any(x => x.IndexOf(":/docker/", StringComparison.OrdinalIgnoreCase) >= 0))
|
if (initProcessCgroup.Any(x => x.IndexOf(":/docker/", StringComparison.OrdinalIgnoreCase) >= 0))
|
||||||
{
|
{
|
||||||
throw new NotSupportedException("Container feature is not supported when runner is already running inside container.");
|
throw new NotSupportedException("Container feature is not supported when runner is already running inside container.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
|
|||||||
Reference in New Issue
Block a user