Changeset 2587
- Timestamp:
- 24/11/2009 22:32:13 (2 years ago)
- File:
-
- 1 edited
-
box/trunk/lib/server/ServerStream.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/server/ServerStream.h
r2415 r2587 303 303 if(ForkToHandleRequests && !IsSingleProcess()) 304 304 { 305 int status = 0; 306 int p = 0; 307 do 308 { 309 if((p = ::waitpid(0 /* any child in process group */, &status, WNOHANG)) == -1 310 && errno != ECHILD && errno != EINTR) 311 { 312 THROW_EXCEPTION(ServerException, ServerWaitOnChildError) 313 } 314 } while(p > 0); 305 WaitForChildren(); 315 306 } 316 307 #endif // !WIN32 … … 326 317 DeleteSockets(); 327 318 } 319 320 #ifndef WIN32 // no waitpid() on Windows 321 void WaitForChildren() 322 { 323 int p = 0; 324 do 325 { 326 int status = 0; 327 p = ::waitpid(0 /* any child in process group */, 328 &status, WNOHANG); 329 330 if(p == -1 && errno != ECHILD && errno != EINTR) 331 { 332 THROW_EXCEPTION(ServerException, 333 ServerWaitOnChildError) 334 } 335 else if(p == 0) 336 { 337 // no children exited, will return from 338 // function 339 } 340 else if(WIFEXITED(status)) 341 { 342 BOX_INFO("child process " << p << " " 343 "terminated normally"); 344 } 345 else if(WIFSIGNALED(status)) 346 { 347 int sig = WTERMSIG(status); 348 BOX_ERROR("child process " << p << " " 349 "terminated abnormally with " 350 "signal " << sig); 351 } 352 else 353 { 354 BOX_WARNING("something unknown happened " 355 "to child process " << p << ": " 356 "status = " << status); 357 } 358 } 359 while(p > 0); 360 } 361 #endif 328 362 329 363 virtual void HandleConnection(StreamType &rStream)
Note: See TracChangeset
for help on using the changeset viewer.
