Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: manpage mentions old TIMEFMT



On Sat, 14 Apr 2012 16:32:48 +0200
Christian Neukirchen <chneukirchen@xxxxxxxxx> wrote:
> >> Finally, %X and %D are rubbish on Linux (but GNU time(1) always shows
> >> 0 for them).
> 
> I'd prefer if they were 0 instead of -9223372036854775808...

I don't know where this is coming from, but the shell does initialise
the structure when it's created, so something in the shell is actually
setting a value --- unless it's the effect of dividing by a zero total
time.

Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.88
diff -p -u -r1.88 jobs.c
--- Src/jobs.c	28 Aug 2011 16:38:28 -0000	1.88
+++ Src/jobs.c	14 Apr 2012 20:53:31 -0000
@@ -716,17 +716,22 @@ printtime(struct timeval *real, child_ti
 #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) || \


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author