| 301 | |
| 302 | |
| 303 | Result<ContainerTermination> getContainerTermination( |
| 304 | const string& runtimeDir, |
| 305 | const ContainerID& containerId) |
| 306 | { |
| 307 | const string path = path::join( |
| 308 | getRuntimePath(runtimeDir, containerId), |
| 309 | TERMINATION_FILE); |
| 310 | |
| 311 | if (!os::exists(path)) { |
| 312 | // This is possible because we don't atomically create the |
| 313 | // directory and write the 'TERMINATION' file and thus we might |
| 314 | // terminate/restart after we've created the directory but |
| 315 | // before we've written the file. |
| 316 | return None(); |
| 317 | } |
| 318 | |
| 319 | Result<ContainerTermination> termination = |
| 320 | state::read<ContainerTermination>(path); |
| 321 | |
| 322 | if (termination.isError()) { |
| 323 | return Error("Failed to read termination state of container: " + |
| 324 | termination.error()); |
| 325 | } |
| 326 | |
| 327 | return termination; |
| 328 | } |
| 329 | |
| 330 | |
| 331 | string getStandaloneContainerMarkerPath( |