Waits for events from the child. */
| 971 | |
| 972 | /* Waits for events from the child. */ |
| 973 | static void debug_parent_wait( int print_message ) |
| 974 | { |
| 975 | int ch = fgetc( command_child ); |
| 976 | if ( ch == DEBUG_MSG_BREAKPOINT ) |
| 977 | { |
| 978 | debug_parent_on_breakpoint(); |
| 979 | } |
| 980 | else if ( ch == DEBUG_MSG_END_STEPPING ) |
| 981 | { |
| 982 | debug_parent_on_end_stepping(); |
| 983 | } |
| 984 | else if ( ch == DEBUG_MSG_SETUP ) |
| 985 | { |
| 986 | /* FIXME: This is handled in the caller, but it would make |
| 987 | more sense to handle it here. */ |
| 988 | return; |
| 989 | } |
| 990 | else if ( ch == EOF ) |
| 991 | { |
| 992 | #if NT |
| 993 | WaitForSingleObject( child_handle, INFINITE ); |
| 994 | if ( print_message ) |
| 995 | { |
| 996 | DWORD exit_code; |
| 997 | GetExitCodeProcess( child_handle, &exit_code ); |
| 998 | debug_parent_child_exited( (int)child_pid, (int)exit_code ); |
| 999 | } |
| 1000 | CloseHandle( child_handle ); |
| 1001 | #else |
| 1002 | int status; |
| 1003 | int pid; |
| 1004 | while ( ( pid = waitpid( child_pid, &status, 0 ) ) == -1 ) |
| 1005 | if ( errno != EINTR ) |
| 1006 | break; |
| 1007 | if ( print_message ) |
| 1008 | { |
| 1009 | if ( WIFEXITED( status ) ) |
| 1010 | debug_parent_child_exited( child_pid, WEXITSTATUS( status ) ); |
| 1011 | else if ( WIFSIGNALED( status ) ) |
| 1012 | debug_parent_child_signalled( child_pid, WTERMSIG( status ) ); |
| 1013 | } |
| 1014 | #endif |
| 1015 | fclose( command_child ); |
| 1016 | fclose( command_output ); |
| 1017 | debug_state = DEBUG_NO_CHILD; |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | /* Prints the message for starting the child. */ |
| 1022 | static void debug_parent_run_print( int argc, const char * * argv ) |
no test coverage detected