zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: Documentation of the TIMEFMT variable
Date: Mon, 27 Mar 2023 09:55:22 +0900	[thread overview]
Message-ID: <E4C0C6FF-1041-4B13-AEF1-EC858A8D79A0@kba.biglobe.ne.jp> (raw)
In-Reply-To: <22159-1679669011.740622@zxQ6.l-QA.Tf8F>



> 2023/03/24 23:43、Oliver Kiddle <opk@zsh.org>のメール:

>> Is there anyone who can confirm that ru_maxrss is set to zero?
>> If it is always zero, then we need not bother with page to KB conversion.
> 
> It does appear to always be zero.

Thanks. I hope the following is enough:


diff --git a/Src/jobs.c b/Src/jobs.c
index 59ddd952e..4d7172550 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -888,8 +888,13 @@ printtime(struct timeval *real, child_times_t *ti, char *desc)
 		break;
 #endif
 #ifdef HAVE_STRUCT_RUSAGE_RU_MAXRSS
+#ifdef RU_MAXRSS_IS_IN_BYTES
+# define MAXRSS_IN_KB(x) ((x)/1024)
+#else
+# define MAXRSS_IN_KB(x) (x)
+#endif
 	    case 'M':
-		fprintf(stderr, "%ld", ti->ru_maxrss / 1024);
+		fprintf(stderr, "%ld", MAXRSS_IN_KB(ti->ru_maxrss));
 		break;
 #endif
 #ifdef HAVE_STRUCT_RUSAGE_RU_MAJFLT
@@ -1036,7 +1041,7 @@ should_report_time(Job j)
 
 #ifdef HAVE_GETRUSAGE
     if (reportmemory >= 0 &&
-	j->procs->ti.ru_maxrss / 1024 > reportmemory)
+	MAXRSS_IN_KB(j->procs->ti.ru_maxrss) > reportmemory)
 	return 1;
 #endif
 
diff --git a/configure.ac b/configure.ac
index f340d2993..e6ced85d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1965,6 +1965,15 @@ if test x$ac_cv_func_getrusage = xyes; then
 #endif
 #include <sys/resource.h>])
 fi
+dnl On some OSes (only macOS?) ru_maxrss is in bytes (not in kilobytes).
+dnl Solaris uses pages as the unit, but ru_maxrss is set to zero anyway.
+AH_TEMPLATE(RU_MAXRSS_IS_IN_BYTES,
+[Define to 1 if ru_maxrss in struct rusage is in bytes.])
+case "$host_os" in
+  darwin*)
+    AC_DEFINE(RU_MAXRSS_IS_IN_BYTES)
+  ;;
+esac
 
 
 dnl --------------------------------------------





      reply	other threads:[~2023-03-27  0:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 16:53 trillian
2023-02-02 17:53 ` Daniel Shahaf
2023-02-02 19:33 ` Bart Schaefer
2023-02-03 20:52   ` Stephane Chazelas
2023-02-05  8:36     ` Daniel Shahaf
2023-03-24 10:25     ` Jun T
2023-03-24 14:43       ` Oliver Kiddle
2023-03-27  0:55         ` Jun T [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E4C0C6FF-1041-4B13-AEF1-EC858A8D79A0@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).