| 288 | } |
| 289 | |
| 290 | void |
| 291 | RestoreTarget::createProcess(bool createIndependentRootProcesses) |
| 292 | { |
| 293 | initialize(); |
| 294 | |
| 295 | if (allowedModes == COORD_NEW) { |
| 296 | allowedModes = COORD_ANY; // we have coord; restore default of COORD_ANY |
| 297 | } |
| 298 | |
| 299 | JTRACE("Creating process during restart")(upid())(procname()); |
| 300 | JTRACE("Creating process during restart")(upid())(procname()); |
| 301 | |
| 302 | RestoreTargetMap::iterator it; |
| 303 | for (it = targets.begin(); it != targets.end(); it++) { |
| 304 | RestoreTarget *t = it->second; |
| 305 | if (upid() == t->upid()) { |
| 306 | continue; |
| 307 | } else if (t->uppid() == upid() && t->sid() != pid()) { |
| 308 | t->createDependentChildProcess(); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | if (createIndependentRootProcesses) { |
| 313 | RestoreTargetMap::iterator it; |
| 314 | for (it = independentProcessTreeRoots.begin(); |
| 315 | it != independentProcessTreeRoots.end(); it++) { |
| 316 | RestoreTarget *t = it->second; |
| 317 | if (t != this) { |
| 318 | t->createDependentNonChildProcess(); |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | // If we were the session leader, become one now. |
| 324 | if (sid() == pid()) { |
| 325 | if (getsid(0) != pid()) { |
| 326 | JWARNING(setsid() != -1) |
| 327 | (getsid(0))(JASSERT_ERRNO) |
| 328 | .Text("Failed to restore this process as session leader."); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | // Now recreate processes with sid == _pid |
| 333 | for (it = targets.begin(); it != targets.end(); it++) { |
| 334 | RestoreTarget *t = it->second; |
| 335 | if (upid() == t->upid()) { |
| 336 | continue; |
| 337 | } else if (t->sid() == pid()) { |
| 338 | if (t->uppid() == upid()) { |
| 339 | t->createDependentChildProcess(); |
| 340 | } else if (t->isRootOfProcessTree()) { |
| 341 | t->createDependentNonChildProcess(); |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | // Now close all open fds except _fd; |
| 347 | for (it = targets.begin(); it != targets.end(); it++) { |
no test coverage detected