| 813 | |
| 814 | |
| 815 | static int try_kill_one() |
| 816 | { |
| 817 | /* Only need to check if a timeout was specified with the -l option. */ |
| 818 | if ( globs.timeout > 0 ) |
| 819 | { |
| 820 | int i; |
| 821 | for ( i = 0; i < globs.jobs; ++i ) |
| 822 | if ( cmdtab[ i ].pi.hProcess ) |
| 823 | { |
| 824 | double const t = running_time( cmdtab[ i ].pi.hProcess ); |
| 825 | if ( t > (double)globs.timeout ) |
| 826 | { |
| 827 | /* The job may have left an alert dialog around, try and get |
| 828 | * rid of it before killing the job itself. |
| 829 | */ |
| 830 | close_alert( &cmdtab[ i ].pi ); |
| 831 | /* We have a "runaway" job, kill it. */ |
| 832 | kill_process_tree( cmdtab[ i ].pi.dwProcessId, |
| 833 | cmdtab[ i ].pi.hProcess ); |
| 834 | /* And return its running commands table slot. */ |
| 835 | return i; |
| 836 | } |
| 837 | } |
| 838 | } |
| 839 | return -1; |
| 840 | } |
| 841 | |
| 842 | |
| 843 | static void close_alerts() |
no test coverage detected