From b8d7e068fc930321dbd1d9850ef8e6e1203e99d9 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 15 Apr 2012 13:46:35 +0000 Subject: 30410 plus one other case: avoid divide-by-zero errors in TIMEFMT interpretation --- Src/jobs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Src') diff --git a/Src/jobs.c b/Src/jobs.c index 94d25bb85..b17060175 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -716,17 +716,22 @@ printtime(struct timeval *real, child_times_t *ti, char *desc) #endif #ifdef HAVE_STRUCT_RUSAGE_RU_IXRSS case 'X': - fprintf(stderr, "%ld", (long)(ti->ru_ixrss / total_time)); + fprintf(stderr, "%ld", + total_time ? + (long)(ti->ru_ixrss / total_time) : + (long)0); break; #endif #ifdef HAVE_STRUCT_RUSAGE_RU_IDRSS case 'D': fprintf(stderr, "%ld", + total_time ? (long) ((ti->ru_idrss #ifdef HAVE_STRUCT_RUSAGE_RU_ISRSS + ti->ru_isrss #endif - ) / total_time)); + ) / total_time) : + (long)0); break; #endif #if defined(HAVE_STRUCT_RUSAGE_RU_IDRSS) || \ @@ -735,6 +740,7 @@ printtime(struct timeval *real, child_times_t *ti, char *desc) case 'K': /* treat as D if X not available */ fprintf(stderr, "%ld", + total_time ? (long) (( #ifdef HAVE_STRUCT_RUSAGE_RU_IXRSS ti->ru_ixrss @@ -747,7 +753,8 @@ printtime(struct timeval *real, child_times_t *ti, char *desc) #ifdef HAVE_STRUCT_RUSAGE_RU_ISRSS + ti->ru_isrss #endif - ) / total_time)); + ) / total_time) : + (long)0); break; #endif #ifdef HAVE_STRUCT_RUSAGE_RU_MAXRSS -- cgit 1.4.1