Compare commits

...

1 Commits

Author SHA1 Message Date
Thomas Boop
c9924d5b7c Check if file exists before reading 2020-01-03 15:02:47 -05:00

View File

@@ -62,10 +62,15 @@ 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";
if (initProcessCgroup.Any(x => x.IndexOf(":/docker/", StringComparison.OrdinalIgnoreCase) >= 0)) // OSX does not have this file, but you cannot run OSX as a base image for docker containers currently.
if (File.Exists(path))
{ {
throw new NotSupportedException("Container feature is not supported when runner is already running inside container."); var initProcessCgroup = File.ReadLines(path);
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.");
}
} }
#endif #endif